+smtp_login -erreur pour autre que GMAIL [stable~40]
This commit is contained in:
parent
23140cc097
commit
7851f4c0fa
|
@ -1,3 +1,4 @@
|
|||
smtp_server = smtp.gmail.com
|
||||
smtp_port = 587
|
||||
mail_address = test@mail.com
|
||||
smtp_server = smtp1.iut-tlse3.fr
|
||||
smtp_port = 465
|
||||
smtp_login = mrd1609a
|
||||
mail_address = mrd1609a
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
|
||||
coucou test :p
|
||||
P
|
|
@ -9,6 +9,7 @@ then # si 1 paramètre
|
|||
'init') # initialise le contenu du fichier de config
|
||||
echo "smtp_server = smtp.gmail.com" > "$path/.config"
|
||||
echo "smtp_port = 587" >> "$path/.config"
|
||||
echo "smtp_login = equal_mailadress_or_different_login" >> "$path/.config"
|
||||
echo "mail_address = test@mail.com" >> "$path/.config"
|
||||
;;
|
||||
'config') nano "$path/.config";; # ouvre en modification le fichier de config
|
||||
|
|
|
@ -20,7 +20,7 @@ def getConf(pPath):
|
|||
confVal = i[i.index('=')+1:].replace(' ', '').replace('\n', '');
|
||||
conf[confKey] = confVal;
|
||||
|
||||
if( len(conf) == 3 ): # si le fichier de config est bien récupéré et qu'il est complet
|
||||
if( len(conf) == 4 ): # si le fichier de config est bien récupéré et qu'il est complet
|
||||
return conf;
|
||||
else:
|
||||
return False;
|
||||
|
@ -29,6 +29,7 @@ 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']) );
|
||||
try:
|
||||
pMsg = MIMEMultipart();
|
||||
pMsg['From'] = pConf['mail_address'];
|
||||
|
@ -37,19 +38,20 @@ def sendMail(pConf, pPass, pTo, pSubject, pMessage):
|
|||
|
||||
pMsg.attach( MIMEText(pMessage.encode('utf-8')) );
|
||||
|
||||
srv = smtplib.SMTP(pConf['smtp_server'], pConf['smtp_port']);
|
||||
srv.ehlo();
|
||||
srv.starttls();
|
||||
srv.ehlo();
|
||||
srv.login(pConf['mail_address'], pPass);
|
||||
|
||||
if( srv.has_extn('STARTTLS') ):
|
||||
srv.starttls();
|
||||
srv.ehlo();
|
||||
|
||||
srv.login(pConf['smtp_login'], pPass);
|
||||
srv.sendmail( pConf['mail_address'], pTo, pMsg.as_string() );
|
||||
srv.quit();
|
||||
|
||||
print "> Mail envoye !";
|
||||
except smtplib.SMTPAuthenticationError:
|
||||
print "> Mauvais login ou mot de passe\n\(enigmail config) pour changer votre adresse";
|
||||
|
||||
finally:
|
||||
srv.quit();
|
||||
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue