Mail versenden via Python

Plaintext Mail via Python. Fehlerbehandlung fehlt.

Like it? Share it!
# Import smtplib to provide email functions import smtplib # Import mail module from email.mime.text import MIMEText # Define email addresses to use addr_to = 'an@beispiel.com' addr_from = 'von@beispiel.com' # Define SMTP email server details smtp_server = 'mail.example.com' smtp_user = 'user@example.com' smtp_pass = '1234567889' # Construct email msg = MIMEText('Testmail-Text') msg['To'] = addr_to msg['From'] = addr_from msg['Subject'] = 'Testmail ' # Send the message via an SMTP server s = smtplib.SMTP(smtp_server) s.login(smtp_user,smtp_pass) s.sendmail(addr_from, addr_to, msg.as_string()) s.quit()

>_ Author Guest

>_ last updated 4 yearss ago

>_ Language: Python

Mail