3

I'm trying to use net-enabled Arduinos to instrument some stuff around the house. For example, I'd like my dryer to text me when it's finished. So it would be useful to have a local mail server on a Linux box, that the Arduino could communicate with (unencrypted) using SMTP commands. The server would forward the Arduino-generated message to phone-number@mms.att.net, eventually resulting in my receiving the text. I'll never need to receive email with this server, and I don't want to have the Arduinos communicating outside my local network.

Is it possible to set up a mail forwarder like that, without having a domain name?

5
  • How do you expect the Arduinos to reach mms.att.net if you don't want it to communicate with the outside? Jul 2 '16 at 20:04
  • 1
    That's the point I'm trying to make. The Arduinos send email to the local email server, which forwards it to mms.att.net.
    – TheGear
    Jul 2 '16 at 20:17
  • Not sure what you don't understand but you only have two choices: let the Aduinos communicate with the Internet and allow it to do what you want or block it and prevent what you want from being possible. You make that decision. The configurations needed to send email don't require you to have a domain name to yourself, but could be done using an email address you have which you could use for sending. Jul 2 '16 at 20:23
  • I'd advertise a service on the local server (only towards the local network) and craft the email on the local server. i.e. the arduinos will not need to talk SMTP (that's a lot of processing for an arduino) just send a simple message to the local server. Most distros today run postfix on the default install, that's enough to send an email given that you have a connection to the internet. Just, as Julie says, you might need to hack the From: header to point to a real email with a real domain (this is often needed to get past the most trivial spam detectors).
    – grochmal
    Jul 2 '16 at 20:29
  • The Arduinos don't have enough power or RAM to do encrypted communications, so if they were to do their own email transfer they'd have to send the email password in the clear, which I don't want. And if you're doing residential networking with ATT, the price of poker goes way up if you want an MX record in the system -- which is why the question about not having a domain.
    – TheGear
    Jul 2 '16 at 20:31
2

The Arduinos can all be fine sendmail email to the outside without (direct) Internet access.

For that you need to:

  • setup a email relay in port 25, for instance postfix, in a box with Internet access, authorising your internal network, or the arduino network in case they are a separate lan/VLAN
  • use APIs in your code for sendmail mail from the Arduinos that are based in communicating with port 25 via TCP, and not via the sendmail API. Designate the relay/proxy machine via IP as the SMTP relay. (smtplib in python if given an SMTP address for instance)
  • Designate the FROM address as something with a domain existing outside, or more rarely depending on the server you are talking to, with an existing email; otherwise anti-spam measures with drop the email. (this is important, more often than not the tickets I get from developers are due to this). The domain of the email does not need to be your own but will get less spam points if it is.

If in the future, you need to setup other more potent Linux boxes (i.e. raspberry pi or clones), ssmtp is also a good and very lightweight service to be able to use the more efficient sendmail API to relay email from a box without direct Internet access (that is what I am using).

Actually, the difficult part is not dealing with the arduinos sending email without Internet connectivity; it is due to possible anti-spam and security measures from the SMTP server and/or your home ISP. For instance, in some parts of the world, ISPs routinely block the 25/TCP port (SMTP) for home customers. If it comes to that, I would suggest opening another complementary question.

1

Write a little "proxy" script.

Something, that runs e.g. netcat or socat with a port listening on the internal network interface your arduinos are connected to. socat then feeds it to a e.g. shell script, that uses a batch mail client to send the mail via mms.att.net for each "telegram" received from the arduinos.

If you dont need to send anything back, It could be as easy as:

nc -k -l 8888 | while read sender telegram ; do echo $sender sent: $telegram ; done

Then replace the echo call with something like mail -s $sender $telegram <other_options>. Add some "error handling" if wanted/needed.

If you have to use SMTP commands on the arduinos to send (instead of raw text over TCP connect), then you'll have to rig up something with e.g. expect to answer the correct things, after the arduinos send MAIL FROM: .... RCPT TO: .... etc.

2
  • Thanks for the reminder about 'expect', Alex. It's been so long since I've used it that I almost forgot about it.
    – TheGear
    Jul 2 '16 at 20:34
  • You could also do it all in a "simple" scripting language like python, instead of using socat for listening, expect for answering, and sh for gluing it all together. Or any language really. Jul 2 '16 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.