try:
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
except:
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
server = "smtp.gmx.com"
username= "[email protected]"
password = "Password123#"
mailfrom = "[email protected]"
mailto = "[email protected]"
msg = MIMEMultipart()
filename="text.txt"
f = open(filename)
attachment= MIMEText(f.read())
attachment.add_header('Content-Disposition', 'attachment', filename=filename)
msg.attach(attachment)
mailer = smtplib.SMTP(server, 587)
mailer.starttls()
mailer.login(username, password)
mailer.sendmail(mailfrom, mailto, msg.as_string())
mailer.close()
Comments