Guest User

Pec

a guest
Oct 17th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import smtplib
  2. from email.mime.text import MIMEText
  3.  
  4. SMTP_SERVER = 'smtp.pec.aruba.it'
  5. SMTP_PORT = 587
  6. FROM_EMAIL = ''
  7. PASSWORD = ''
  8.  
  9. TO_EMAIL = '[email protected]'
  10. SUBJECT = 'Test PEC Email'
  11.  
  12. msg = MIMEText('This is a test PEC email.')
  13. msg['Subject'] = SUBJECT
  14. msg['From'] = FROM_EMAIL
  15. msg['To'] = TO_EMAIL
  16.  
  17. server = None
  18.  
  19. try:
  20.     server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
  21.     server.starttls()
  22.     server.login(FROM_EMAIL, PASSWORD)
  23.     server.sendmail(FROM_EMAIL, TO_EMAIL, msg.as_string())
  24.  
  25. except Exception as e:
  26.     print(f"An error occurred: {e}")
  27. finally:
  28.     if server:
  29.         server.quit()
Advertisement
Add Comment
Please, Sign In to add comment