K'NEK-TEK

A webpage to document and share my open-source software/hardware projects.

Home » How to send email from the Beaglebone Black with a Gmail account

How to send email from the Beaglebone Black with a Gmail account

Michael Hirsch’s great script checkIP sends an email to you when the IP address of a given computer changes, so you can still ssh into a machine even if Comcast or some other ISP has changed the IP on you (that happens every few months to most residential networks). However there are some problems you’ll run in to if you want to send emails from the command line at a residential address, since Comcast and others block commonly used email ports to prevent spam.

One way around this is to use a Gmail account to send the email for you, while still being able to send it from a Beaglebone. I followed the steps here (and thanks very much to user tcb2 for posting that!) but they need to be altered to work because that post assumes the user has an account with that mailing list. Here are the steps I used to send emails from the Beaglebone Black hooked up at my home:

  1. Install w3m on the beaglebone so you can visit Google’s authentication website from the command line (unless you have a graphical interface set up for your BBB). Then visit http://www.google.com/accounts/DisplayUnlockCaptcha by typing:

    on the command line in your BBB. Enter the email and password you want to use and follow the instructions. Make sure to keep the “stay logged in” box checked. After you’ve done all that, quit out of w3m by typing “q” and answering “y”, then log in to your email on a computer and check google’s message about the recent attempt to log in. Go into your account security settings and confirm that you want that device to be able to access your account. The reason you need to do this is because the BBB will be sending emails on behalf of that account.
  2. Open port 587 on your router and forward it to the BBB.
  3. Install and configure exim4 as root (exim4 is the program that will send the emails) using:

    In the dialog, answer like so:
Configuration type  mail sent by smarthost; received via SMTP or fetchmail
 System mail name  localhost
 IP-addresses to listen on for incoming SMTP connections  127.0.0.1 ; ::1
Other destinations for which mail is accepted (leave empty)
Machines to relay mail for (leave empty)
IP address or host name of the outgoing smarthost smtp.gmail.com::587
Hide local mail name in outgoing mail ? yes
Keep number of DNS-queries minimal (Dial-on-Demand) ? no
Delivery method for local mail mbox format in /var/mail/
Split configuration into small files ? no

Then check /etc/exim4/update-exim4.conf.conf and make sure the settings are as shown:

4. Modify /etc/exim4/passwd.client with your own gmail username and password as shown:

5. The permissions are probably already set correctly but if not, make sure they’re restricted to root:Debian-exim and only root can read and write to the file (chmod 640).

6. Restart the exim4 daemon:

7. All done! Now you can send email from your beaglebone by formatting an ASCII files as follows:

and sending that file (let’s call it email.txt) with:

where the -t option causes sendmail to get the needed to: and from: and subject: info from the text file.

2 thoughts on “How to send email from the Beaglebone Black with a Gmail account

  • Also on an unrelated note, it could substitute for the php mail function thus sending your email securely and depositing a copy of the email in your gmail sent box.

    Reply
  • how can i attach files by using this ssmtp mta. i am able to send mails by using ssmtp very comforbly, . plese help how can i do email-attachments with ssmtp?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *