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!
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:
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
me@my.beaglebo.ne volkalert@gmail.com' 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
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…
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.