diff --git a/enigmail/.config b/enigmail/.config index 72cc7aa..e710aba 100644 --- a/enigmail/.config +++ b/enigmail/.config @@ -1,13 +1,13 @@ -smtp_server = smtp.gmail.com -smtp_port = 587 +smtp_server = smtp1.iut-tlse3.fr +smtp_port = 465 imap_server = imap.gmail.com imap_port = 993 mail_address = doowap31@gmail.com -login = doowap31@gmail.com +login = mrd1609a algorithm_complexity = 1 -text_editor = nano +text_editor = gedit diff --git a/enigmail/source/enigmail.py b/enigmail/source/enigmail.py index fc8c53f..0d9c13f 100644 --- a/enigmail/source/enigmail.py +++ b/enigmail/source/enigmail.py @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- +import sys +import datetime import email import imaplib import smtplib -from email.MIMEMultipart import MIMEMultipart -from email.MIMEText import MIMEText +import email.utils +from email.mime.text import MIMEText @@ -47,29 +49,38 @@ def getConf(pPath): # cette fonction envoie un mail def sendMail(pConf, pPass, pTo, pSubject, pMessage): - srv = smtplib.SMTP(pConf['smtp_server'], int(pConf['smtp_port']) ); + # Définition du serveur SMTP + srv = smtplib.SMTP(); + srv.connect( pConf['smtp_server'], pConf['smtp_port'] ); + try: - pMsg = MIMEMultipart(); - pMsg['From'] = pConf['mail_address']; - pMsg['To'] = pTo; - pMsg['Subject'] = "[ENIGMAIL] "+pSubject; + # formattage du message et du header + msg = MIMEText( pMessage.encode('utf-8') ); + msg.set_unixfrom('author'); + msg['To'] = email.utils.formataddr(('Author', pTo)); + msg['From'] = email.utils.formataddr(('Recipient', pConf['mail_address'] )); + msg['Subject'] = "[ENIGMAIL] "+pSubject; - pMsg.attach( MIMEText(pMessage.encode('utf-8')) ); + # activation du log + srv.set_debuglevel(True); + # Identification de la connection srv.ehlo_or_helo_if_needed(); - if( srv.has_extn('STARTTLS') ): - srv.starttls(); - srv.ehlo_or_helo_if_needed(); + if( srv.has_extn('STARTTLS') ): # Si on doit encrypter la session + srv.starttls(); # on encrypte la session + srv.ehlo_or_helo_if_needed(); # on se ré-identifie à travers la connection sécurisée + # connection au serveur avec le login du config-file et le mot de passe passé en paramètre srv.login(pConf['login'], pPass); - srv.sendmail( pConf['mail_address'], pTo, pMsg.as_string() ); + # envoi du mail (formattage du message) + srv.sendmail( pConf['mail_address'], [pTo], msg.as_string() ); print "> Mail envoye !"; - except smtplib.SMTPAuthenticationError: + except smtplib.SMTPAuthenticationError: # message d'alerte si mauvais identifiants print "> Mauvais login ou mot de passe\n\(enigmail config) pour changer votre adresse"; finally: - srv.quit(); + srv.quit(); # quitte le serveur si déroulement normal ou exception # cette fonction récupère les mails def getMail(pConf, pPass): diff --git a/enigmail/source/enigmail.pyc b/enigmail/source/enigmail.pyc index 7488fd6..7db8416 100644 Binary files a/enigmail/source/enigmail.pyc and b/enigmail/source/enigmail.pyc differ diff --git a/enigmail/source/test b/enigmail/source/test new file mode 100644 index 0000000..4199e31 --- /dev/null +++ b/enigmail/source/test @@ -0,0 +1,14 @@ +^CTraceback (most recent call last): + File "/home/user/Bureau/GITHUB/Enigmail.py/enigmail/source/send.py", line 21, in + sendMail(conf, Pass, To, Subj, m); + File "/home/user/Bureau/GITHUB/Enigmail.py/enigmail/source/enigmail.py", line 53, in sendMail + srv = smtplib.SMTP( pConf['smtp_server'], pConf['smtp_port'] ); + File "/usr/lib/python2.7/smtplib.py", line 251, in __init__ + (code, msg) = self.connect(host, port) + File "/usr/lib/python2.7/smtplib.py", line 312, in connect + (code, msg) = self.getreply() + File "/usr/lib/python2.7/smtplib.py", line 356, in getreply + line = self.file.readline() + File "/usr/lib/python2.7/socket.py", line 447, in readline + data = self._sock.recv(self._rbufsize) +KeyboardInterrupt diff --git a/enigmail/source/test_ b/enigmail/source/test_ new file mode 100644 index 0000000..ca838df --- /dev/null +++ b/enigmail/source/test_ @@ -0,0 +1,15 @@ +^CTraceback (most recent call last): + File "/home/user/Bureau/GITHUB/Enigmail.py/enigmail/source/send.py", line 21, in + sendMail(conf, Pass, To, Subj, m); + File "/home/user/Bureau/GITHUB/Enigmail.py/enigmail/source/enigmail.py", line 53, in sendMail + srv = smtplib.SMTP(pConf['smtp_server'], int(pConf['smtp_port']) ); + File "/usr/lib/python2.7/smtplib.py", line 251, in __init__ + (code, msg) = self.connect(host, port) + File "/usr/lib/python2.7/smtplib.py", line 312, in connect + (code, msg) = self.getreply() + File "/usr/lib/python2.7/smtplib.py", line 356, in getreply + line = self.file.readline() + File "/usr/lib/python2.7/socket.py", line 447, in readline + data = self._sock.recv(self._rbufsize) +KeyboardInterrupt +