How to Send email via Beaglebone Black?

824 views
Skip to first unread message

volk...@gmail.com

unread,
Aug 19, 2016, 11:01:44 AM8/19/16
to BeagleBoard
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!


Some other links I've been using:

Przemek Klosowski

unread,
Aug 19, 2016, 11:45:04 AM8/19/16
to beagl...@googlegroups.com
On Fri, Aug 19, 2016 at 11:01 AM, <volk...@gmail.com> wrote:
I want my Beaglebone Black (BBB) to send me an email when a button wired to it is pushed.
 
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)

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
data
button pressed
.
quit

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 m...@my.beaglebo.ne volk...@gmail.com'  command and pipe your message to its stdin.

volk...@gmail.com

unread,
Aug 19, 2016, 1:58:53 PM8/19/16
to BeagleBoard

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) 

Wally Bkg

unread,
Aug 19, 2016, 4:09:54 PM8/19/16
to BeagleBoard
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.

Mark A. Yoder

unread,
Aug 20, 2016, 11:06:45 AM8/20/16
to BeagleBoard
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  https://support.google.com/accounts/answer/185833 v7sm4244267ita.9 - gsmtp]
  code: 'EAUTH',
  response: '534-5.7.9 Application-specific password required. Learn more at\n534 5.7.9  https://support.google.com/accounts/answer/185833 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...

--Mark

Hồng Quân Nguyễn

unread,
Sep 20, 2016, 1:37:01 AM9/20/16
to BeagleBoard

I use mailgun.com 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': 'nor...@farm.agriconnect.vn',
        'to': addr,
        'subject': _('Data exported for %(cond_type)s') % (
            {'cond_type': cond_type}),
        'text': body
    }
    rsp = requests.post(
        settings.MAILGUN_URL,
        auth=('api', settings.MAILGUN_API_KEY),
        data=message,
        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, volk...@gmail.com đã viết:

William Hermans

unread,
Sep 20, 2016, 4:23:27 AM9/20/16
to beagl...@googlegroups.com
If you google "how to linux email command line" You'll see you do not need anything special to send emails from Linux . . .

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/ba5a0152-b271-44f3-a193-4cf5e37849f3%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

woody stanford

unread,
Jan 28, 2017, 9:59:22 PM1/28/17
to BeagleBoard
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. :)
Reply all
Reply to author
Forward
0 new messages