We have all probably heard of gmail. It is an email you get with a google account. We have probably all heard of what pi is and pi day. Well... in this instructable I will show you how to send an email through the gmail server to a friend saying "Happy Pi Day"
Please note: If you are sending to an email that is not a gmail account, you will need to mark the sender as safe because sometimes it is marked as spam. Let me know if you have trouble and I can help you out.
Don't Have a Google/Gmail Account? Go to: Sign Up for Google
Already have a Google Account? Go to: Sign Into Google to confirm your email address and password
Step 1: Step 1: Download and Install Textwrangler
Download and install TextWrangler. To do this, go to TextWrangler Download Information and select your computer version. Then download. I recommend that you do it from this website because it is the official one and it prevents the likelihood of virus and malware infections.
Once it is done downloading, open it.
Step 2: Step 2: Create the Program
Next, open a new text document.
Then, copy and paste the following into the document:
<p> import smtplib</p><p>smtpUser = 'Your gmail email address' smtpPass = 'Your gmail password' toAdd = 'email to send to' fromAdd = smtpUser subject = 'Happy Pi Day!!!' header = 'To: ' + toAdd + '\n' + 'From: ' + fromAdd + '\n' + 'Subject: ' + subject body = 'This is a message from a Python Script saying: Happy Pi Day!!!' print header + '\n' + body s = smtplib.SMTP('smtp.gmail.com',465) s.ehlo() s.starttls() s.ehlo() s.login(smtpUser, smtpPass) s.sendmail(fromAdd, toAdd, header + '\n\n' + body) print 'done' </p>
If that does not work you can download GMAIL.py and run that instead.
Before you run, you have to change smtpUser to your email. For example: smtpUser = 'email@example.com'
Then change smtpPass to your password to login to google. For example: smtpPass = 'robotman2'
Then change toAdd to the who you are sending to (keep in mind the spam issue you may need to fix first from the first step/Intro) For example: toAdd = 'firstname.lastname@example.org'
You can change the subject and body if you want, but with how it is now, it will send a pi day message.
Then at the top of the screen, go to #!>Run in Terminal
It may take a minute, but it should just run. When it is sent, it will say done.
Note: If you have a firewall blocking the connection, it will not be able to send. Therefore you will get an error after 2-3 minutes of running the program.
If you have any questions, let me know below.
Have a nice day! :)