@@ -0,0 +1,2597 @@
+#!/usr/bin/env python3%0A%0Aimport smtplib%0Afrom email.mime.text import MIMEText%0Afrom string import Template%0Aimport time%0Aimport getpass%0A%0A# In DEGUB mode, emails are sent to this address instead of the true one.%0A# (typically the address of the credential authority)%0ADEBUG=False%0ADEBUG_MAIL='bozo.leclown@example.com'%0A%0A# Edit the following according to your election:%0AFROM='bozo.leclown@example.com' # can be the email of the credential authority%0ASUBJECT='%C3%89lection du meilleur cookie: votre mat%C3%A9riel de vote'%0AUUID='7af1a378-ed25-481a-9775-7b1a7e55c746'%0A%0A# Your outgoing email configuration:%0ASMTP='smtp.example.com'%0Ausername='bozo'%0Apassword = getpass.getpass(%22please type your password: %22)%0A%0A# name of the file where to read the credentials%0ACODE_FILE='codefile.txt'%0A%0A# Edit the email template:%0ATEMPLATE=Template(%22%22%22%0ABonjour,%0A%0ANous vous invitons %C3%A0 participer %C3%A0 l'%C3%A9lection du meilleur cookie%0A%C3%A0 l'adresse suivante:%0A%0A  https://belenios.loria.fr/elections/$UUID/%0A%0AVous aurez besoin de vos identifiants LDAP ou de votre login/mot de%0Apasse, mais aussi du code de vote personnel (appel%C3%A9 %22credential%22) que voici :%0A%0A  $ELECTION_CODE%0A%0ALe scrutin est ouvert du 1 avril %C3%A0 9h au 2 avril %C3%A0 18h.%0A%0AVeillez bien %C3%A0 aller au bout des 6 %C3%A9tapes pour que votre vote soit pris%0Aen compte. Un mail de confirmation vous sera envoy%C3%A9.%0A%0APour rappel, il y a deux candidats : Ma%C3%AFt%C3%A9 et Amandine.%0A%0AMerci de votre participation%0A%0A==========================================================%0A%0AHello,%0A%0AYou are listed as a voter for the election of the best cookie.%0APlease visit the following link:%0A%0A  https://belenios.loria.fr/elections/$UUID/%0A%0AYou will need your LDAP or login / password, and also the following%0Acredential (personal code):%0A%0A  $ELECTION_CODE%0A%0AThe election is open from April 1st, 9am to April 2nd, 6pm.%0A%0ABe sure to go through the 6 steps to ensure that your vote is taken into%0Aaccount. A confirmation email will be sent.%0A%0AReminder: there are two candidates Ma%C3%AFt%C3%A9 and Amandine.%0A%0AThank you for your participation.%0A%22%22%22)%0A%0A# Real stuf starts here. Pretty short, isn't it?%0Awith open(CODE_FILE) as cf:%0A    d = dict(UUID=UUID)%0A    s = smtplib.SMTP(SMTP)%0A    s.starttls()%0A    s.login(username, password)%0A    for line in cf:%0A        l = line.split()%0A        d%5B'ELECTION_CODE'%5D=l%5B1%5D%0A        msg = MIMEText(TEMPLATE.substitute(d))%0A        email=l%5B0%5D.split(%22,%22)%5B0%5D%0A        msg%5B'Subject'%5D = SUBJECT%0A        msg%5B'From'%5D = FROM%0A        if DEBUG:%0A            msg%5B'To'%5D = DEBUG_MAIL%0A        else:%0A            msg%5B'To'%5D = email%0A        s.send_message(msg)%0A        time.sleep(0.2) # short delay; might need more for very large election%0A    s.quit()%0A%0A

Add sample script to send credentials