Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- import email.utils
- from email.mime.text import MIMEText
- # Prompt the user for connection info
- username = raw_input('Your Email:')
- password = raw_input("Your password:")
- to_email = raw_input('Recipient Email:')
- servername = "smtp.gmail.com:587"
- # Create the message
- Subject1 = raw_input("Subject:")
- From1 = raw_input("Name of Sender as:")
- To1 = raw_input("Name of Recipient as:")
- msg = MIMEText(raw_input("Enter message body:"))
- msg.set_unixfrom("")
- msg['Subject'] = Subject1
- msg['From'] = email.utils.formataddr((From1, username))
- msg['To'] = email.utils.formataddr((To1, to_email))
- server = smtplib.SMTP(servername)
- server.starttls()
- server.login(username, password)
- server.sendmail(username, to_email, str(msg))
- # Whats the difference between msg.as_string() and str(msg) ?
- #from asdpoias import asoidjasd , why not just import it all ?
- #Whats msg.set_unixfrom()?
- #and msg[]
Add Comment
Please, Sign In to add comment