Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- from email.mime.text import MIMEText
- SMTP_SERVER = 'smtp.pec.aruba.it'
- SMTP_PORT = 587
- FROM_EMAIL = ''
- PASSWORD = ''
- TO_EMAIL = '[email protected]'
- SUBJECT = 'Test PEC Email'
- msg = MIMEText('This is a test PEC email.')
- msg['Subject'] = SUBJECT
- msg['From'] = FROM_EMAIL
- msg['To'] = TO_EMAIL
- server = None
- try:
- server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
- server.starttls()
- server.login(FROM_EMAIL, PASSWORD)
- server.sendmail(FROM_EMAIL, TO_EMAIL, msg.as_string())
- except Exception as e:
- print(f"An error occurred: {e}")
- finally:
- if server:
- server.quit()
Advertisement
Add Comment
Please, Sign In to add comment