Mark Zachmann
May 31, 2017 · 2 min read

Answer

Before getting into the history. I ended up using Python3 and the smtplib library. Quick, simple, and reliable.

Send email using your Raspberry PI and GMail

History

I’m doing some volunteer work that requires sending group mail with customization. Currently they do this manually using Outlook which seems like a horrible waste of manpower so I thought why not harness a spare Raspberry PI to send mail?

Wow was that harder than I thought. I could send mail to some addresses but not others. The biggest problem was reverse DNS authentication. It turns out that the only reliable way to send email that I found not getting black-listed was to route it through GMail.

So then I looked into GMail via Raspberry PI solutions and I found, as usual, many on the web. Most of these required substantial .INI file modifications and tweaking to alias files and installing guaranteed-latest versions and … you know the drill.

Then it was hours analyzing log files and trying to find out why things didn’t work.

It turns out… there’s a simple way to do this. I like Python on my Raspberry Pi (and other Linux distros). I did this on the latest Jessie-Lite distro.

I use Python3 (not 2.7) because the class support is awesome. Python 2.7 is kind of a toy. Python 3 is a professional product.

Steps to Success

  1. Install Python3

2. Create a GMail account. I built a special account just for bulk mailing because, why not. Also you care a lot less about security.

3. Here’s some sample code that works the first time. You can type this into the interpreter and watch it work line by line or just create a function using similar code. Note that smtplib comes by default.

Simplistic Python send using GMail and Raspberry Pi

Home Wireless

Home automation in the wireless IOT era

Mark Zachmann

Written by

Entrepreneur, software architect, electrical engineer. Ex-academic.

Home Wireless

Home automation in the wireless IOT era

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade