From 8b746742fcf706966b9f175bed490fef9b443a8e Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 26 May 2015 18:51:08 +0200 Subject: [PATCH] =?UTF-8?q?M=C3=A0j=20modifications=20mineures=20smtp=20[s?= =?UTF-8?q?table~80]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- enigmail/.config | 8 +++---- enigmail/source/enigmail.py | 39 ++++++++++++++++++++++------------- enigmail/source/enigmail.pyc | Bin 6923 -> 7098 bytes enigmail/source/test | 14 +++++++++++++ enigmail/source/test_ | 15 ++++++++++++++ 5 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 enigmail/source/test create mode 100644 enigmail/source/test_ 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 7488fd64055582dca2a55569f2087d1c27de072c..7db84160d74d7c20985c88420ea637029f40d432 100644 GIT binary patch delta 1749 zcmaJ>O>A355T1R{e$IRT&!6l5kU&AQT9E^lk{*(RsoFFpNvpLXtwYr~-j~#_|N6Wx zNlD~GDsezmLVE#;0|zb$i32$VRa`iL1QG}dB&1#t2e@zq#03dv#%Y5<;@O_}&F(j| zGqW>(ee(X)5&PG;xA%^Eu>$*#h41I^*Lm>fk&`_EbsI`HC;){x1f|eJ9EOs`*n+wP zjR=$?Ae0Sv0ZId)LJV9`VFn&3hd~rngh33{0E0Lvmq7xQ#~=wR%HT{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5U#A#=z7sxP)*5pS4b>)+^SXIBJ^Vn4uOggTxd7z z)ER(cv*Xh1+QRD6Vt#&U<@HI$o`vpKH7u)6lz3O&d~R07SzDaXQ69iw`}nWB*AofjP% z741_mRciXK^Qv`*y`I2 z&{L^Tv8aDaUBEFmXA=}62+PfStJw*c!`)roN&h~(#(_5oJZbSdF=<3=dEu(R$r2~h zTB&rD;`(d;7@_|Lh1|pg{YU0uM*NHIZs-@;w5Gq$K68}P%)lsqpf3-6J#mvweLFFa zTkPLr*kr0P){0#f>UGs+tJf28D z^Yh!Kw$EktBgjr^K1njfkjr;a7Sm_u*-7Qokq(Q)llA z>v+a;R9pF@<@(IXyZEDiF!JXOUM2qx9<$^2$Wp(_x+;MuXQajAaRzU)*k+LSbciV~ zi$@%UK|!_s?!U)kzpo_S&*ae=A^^0^NjjD%(84i1L5DPFc-%UFp5bMNDFQV}Am?!U ziGQvByJNpmd`6`|O 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 +