How to Send email via Beaglebone Black?

Hello all,

I am trying to do a (presumably) very simple task.
I want my Beaglebone Black (BBB) to send me an email when a button wired to it is pushed.

A) I don’t know for sure if I have Angstrom or Debian (or otherwise?) and I don’t know how to find out
B) I’m aware of email services include msmtp, ssmtp, exim4, etc from my current efforts on the topic, but I don’t know how to download, install, and set them up (or even which one I should use)

Background info: I’m currently using Putty as my terminal to talk to the BBB. I’ve found that I need to connect an ethernet cable directly to the BBB (instead of piggybacking via USB tot he laptop’s wireless) to actually get network capability.

I’ve been working on this for the past few days, but this is my first time getting my hands dirty with a BBB (and Linux, operating systems in general), so most of the tutorials I’ve been reading aren’t very helpful because they assume I know things that I don’t (they say “install this package”…but how?). If we could piece together a sort of step-by-step for this whole process, that would vastly help both myself and anyone else trying to do what I’m doing. Thanks much!

The main tutorial I’m following:

Some other links I’ve been using:

Don't worry about those things---you don't need them. Instead, you need to
figure out how to connect to the email infrastructure that would transmit
your message to the final destination. Getting the email out of your system
is easy---you could literally telnet to port 25 on the mail server that is
accessible to you, and type the commands:

*helo volkalert*

*mail from: <>*

*rcpt to: <>*


*button pressed.*

The trick is to find the mail server that will accept your connection, and
what domains it allows for the to/from data. You have to ask your ISP for
that. Once you know the answer, you could just open the network connection
and issue the command sequence above, or use one of SMTP libraries in the
language you're writing your app in, or simply spawn the 'mail -r' command and pipe your message to
its stdin.

Thanks for the input, though from what I’ve read from a handful of sources (the links I attached), the reason they use the msmtp/ssmtp services is because it’s (reportedly) a lot easier to use those services than to find a server to handle the port 25 requests (instead the services usee either port 587 or port 465, depending on whether msmtp or ssmtp are being used, as I understand)

IMHO the simplest way to do it is setup a free Gmail account and enable imap/pop support on it. Then install mutt on your BBB and configure it to send the email through Gmail. Then on the BBB do something like

system(“echo ‘No Heartbeat:’ /bin/date | /usr/bin/mutt -s ’ Problem!’ – user@domain. ; rm $HOME/sent”);

Google Mutt and Raspberry Pi, there are lots of good tutorials, the mutt setup is the same for the BBB as it is for the Pi. I’m using it on both my BBW and Rpi2.

There’s an email example in the bone101 examples already on the current Bone images. Try:

bone$ cd /usr/share/bone101/examples/cookbook/06-iot (For newest images)
If that doesn’t work try
bone$ cd /var/lib/cloud9/examples/cookbook/06-iot
If that doesn’t work you need to update your image.
Then run:
bone$ npm install -g nodemailer
Now edit the file nodemailer-test.js to use your gmail address and password, and edit the to and from email addresses. Then run:
bone$ ./nodemailer-test.js

{ [Error: Invalid login: 534-5.7.9 Application-specific password required. Learn more at
534 5.7.9 Sign in with App Passwords - Google Account Help v7sm4244267ita.9 - gsmtp]
code: ‘EAUTH’,
response: ‘534-5.7.9 Application-specific password required. Learn more at\n534 5.7.9 Sign in with App Passwords - Google Account Help v7sm4244267ita.9 - gsmtp’,
responseCode: 534,
command: ‘AUTH PLAIN’ }

Go to the URL given to set up your application specific password. Edit nodemailer-test.js to include the new password, then run:
bone$ ./nodemailer-test.js.

Your email should be sent.

This is from the BeagleBone Cookbook. The cookbook has lots of examples like this for doing simple things…


I use to send email. It provides HTTP API.

Here is a part of my code (I use Python and “requests” library to do HTTP request):

message = {
‘from’: ‘’,
‘to’: addr,
‘subject’: _(‘Data exported for %(cond_type)s’) % (
{‘cond_type’: cond_type}),
‘text’: body
rsp =
auth=(‘api’, settings.MAILGUN_API_KEY),
files={‘attachment’: (’{}.csv.gz’.format(filename), stream)}

The email to be sent also have a CSV file attached (I’m implementing data export).

Conversation via HTTP is less overhead than via SMTP, it is better for a low power device like Beagle Bone.

Vào 22:01:44 UTC+7 Thứ Sáu, ngày 19 tháng 8 năm 2016, đã viết:

If you google “how to linux email command line” You’ll see you do not need anything special to send emails from Linux . . .

OK, best way (and this really is an IoT question if you look at it) is to look at the most efficient (ie. fastest, least labor intensive) way of doing it. BBB’s are small, so please don’t try to install an SMTP server and stuff on it when you can do this.

The mutt and the HTTP API approach are great because they transfer the work off the BBB, basically a “client” approach, its called.

What I would do is use CURL to pass via an HTTP POST to your virtual server (ie. your web site) to a really basic PHP script that did the actual mailing. Let me justify my position on this. All the PHP script does is invoke the PHP function mail(to,subject,message) stuffing the data in the POST into this one function (like 10 lines of code maximum). This transfers the work load onto their sys admin saving you a lot of trouble.

On your BBB, access CURL and just build a basic url-encoded GET or POST (POST is preferable) header and execute. Build the full email on the BBB and just pass it to your virtual server script. CURL Execute() allows you to even send back a fail/success code that you can verify that it was sent.

Interesting problem. :slight_smile: