Advertisement
Guest User

yoghi

a guest
Dec 18th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import smtplib
  2. from email.mine.text import MIMEext
  3.  
  4. server = smtplib.mtp('smtp.develmail.com',587)
  5.  
  6. #Mi sono creato un account fasullo su questo server develmail
  7. #così lo possiamo usare senza fare danni!
  8. #il login è fasullo:un nome ed una password di prova!
  9. server.starttls() #il ttls è un protocollo di sicurezza/crittografia
  10. server.login("0CUQJ5QOP2AQ6","2Z6AR6ZNGABQM")
  11.  
  12. #Costruiamo email
  13. msg=MIMEText('Questo è il testo della mail')
  14. msg['To']="bob@mail.com"
  15. msg['From']="alice@mail.com"
  16. msg['Subject']='Test Email con Python'
  17.  
  18. #mittente, destinatario, messaggio
  19. try:
  20. server.sendmail("alice@mail.com","bob@mail.com",msg.as_string())
  21. server.quit()
  22. print ("mail inviata")
  23. except Exception:
  24. print ("Errore mail non inviata")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement