Ethernet Shield: Can it send email?

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
dimeodesign
 
Posts: 3
Joined: Thu Apr 28, 2011 10:42 am

Ethernet Shield: Can it send email?

Post by dimeodesign »

Ethernet Shield: Can it send email?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Ethernet Shield: Can it send email?

Post by adafruit_support_bill »

There is a thread on this over at Arduino.cc: http://www.arduino.cc/cgi-bin/yabb2/YaB ... 1250101892

User avatar
burpees_NH
 
Posts: 74
Joined: Wed Dec 15, 2010 5:31 pm

Re: Ethernet Shield: Can it send email?

Post by burpees_NH »

If you attempt to do SMTP from the Ethernet shield, that thread has an example but know a couple of issues:

1) Your ISP -may- block outbound SMTP (unless it is sent straight to their SMTP server.. meaning you might not be able to send email 'direct' to some MX)
If this is the case, you will need to adapt the example for SMTP Auth, or you will need to have another server (which is not blocked outbound on port 25) do the email for you.

2) If you have to rely on an external server to relay the email, easiest way to get the message from the Arduino to that server is via HTTP.
PHP has a ton of SMTP engines for it, and some are actually nice. I would configure the webhost to relay the email (again!) through a *trusted SMTP server*.

In other words, sending email directly off of a webserver may be possible, but it is a real headache because lots of sites and spam filters will mark webserver email as spam. They might even block the message. Yes this does mean more hops (arduino-->web-->trusted SMTP server) but this is actually quite common.

3) Overall, I would not try to do direct SMTP on the Arduino except as a learning exercise. SMTP is simple to demonstrate, but complex to do correctly.

A real SMTP client needs to handle message retries, graylisting or queuing, LOGGING errors, etc. which would take much space on a 'duino.
Therefore it is best to write a simple HTTP messager on the 'duino (sends a GET or POST request with the 'message'), and talk to a nice featured web->SMTP relay which accepts the HTTP request and captures the message body.


I would have added this info to the Arduino.cc thread, but it's locked because of their forum switch. This page actually came up higher in my Google search anyways. :-)

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Ethernet Shield: Can it send email?

Post by westfw »

A real SMTP client needs to handle message retries, graylisting or queuing, LOGGING errors,
Nonsense. If you don't need any more capabilities than you'd get from an HTTP-based form, you don't have to implement them...

Your point that "simple" SMTP is pretty rare these days (consider that the protocol doesn't have any security) is a good one, though. If you want to send email via "real" mail servers, you might have to implement a bunch of modern features (SSL) that would be hard to implement on a small microcontroller. The easiest thing to do is probably talk trivial SMTP to a local "relay" system (running linux or something), and have THAT use standard email daemons for forwarding to The Internet At Large.

Silo37
 
Posts: 1
Joined: Fri Sep 23, 2011 8:23 am

Re: Ethernet Shield: Can it send email?

Post by Silo37 »

Greetings,

I have been using the examples for the client connect library and can successfully perform a GET /HTTP 1.0 request.
(have even implemented the Ethernet2 DHCP library - which is very cool)....

However, I cannot seem to get a connection to an SMTP server, I've tried, gmail, gmx, yahoo, etc.

I can successfully perform a telnet, with AUTH LOGIN and send an email but just cant seem to get the Arduino to connect.

I'm using an Arduino 22 - is anyone aware of any known issues here? These seems like it would be relatively easy.

User avatar
burpees_NH
 
Posts: 74
Joined: Wed Dec 15, 2010 5:31 pm

Re: Ethernet Shield: Can it send email?

Post by burpees_NH »

westfw wrote:
A real SMTP client needs to handle message retries, graylisting or queuing, LOGGING errors,
Nonsense. If you don't need any more capabilities than you'd get from an HTTP-based form, you don't have to implement them...
What you say is tru only if the poster was mailing to a mail server which he controls. I assumed not, that he would be mailing to a third party server such as yahoo or aol, etc.

Just google any PHP or .net library, any note how many confused users throw up their hands and say 'it does not work', clogging that library's support system.

SMTP is simple on paper, rarely in practice. Simple answers are deceptive.

User avatar
burpees_NH
 
Posts: 74
Joined: Wed Dec 15, 2010 5:31 pm

Re: Ethernet Shield: Can it send email?

Post by burpees_NH »

Silo37 wrote:Greetings,

I have been using the examples for the client connect library and can successfully perform a GET /HTTP 1.0 request.
(have even implemented the Ethernet2 DHCP library - which is very cool)....

However, I cannot seem to get a connection to an SMTP server, I've tried, gmail, gmx, yahoo, etc.

I can successfully perform a telnet, with AUTH LOGIN and send an email but just cant seem to get the Arduino to connect.

I'm using an Arduino 22 - is anyone aware of any known issues here? These seems like it would be relatively easy.

Have you tried reproducing the problem on your host PC? Might be one of the issues I mentioned, earlier. If so, you have to trial an error to work around it.

Hupport
 
Posts: 1
Joined: Mon Oct 10, 2011 2:33 am

Re: Ethernet Shield: Can it send email?

Post by Hupport »

It's not possible to make a SMTP request with the Ethernet shield.

But if you have a webserver you could make a PHP script which the Ethernet shield call, and then it sends the email. <- That's what I'm doing!
Last edited by Hupport on Tue Jun 19, 2012 2:53 am, edited 2 times in total.

User avatar
burpees_NH
 
Posts: 74
Joined: Wed Dec 15, 2010 5:31 pm

Re: Ethernet Shield: Can it send email?

Post by burpees_NH »

Hupport wrote:It's not possible to make a SMTP request with the Ethernet shield.

But if you have a webserver you could make a PHP script which the Ethernet shield call, and then it sends the email. <- That's what I'm doing!
Hi Hupport,

It's not that you "can not" make SMTP calls with the Ethernet shield. You can, and I have done it. But just because something is possible, does not mean it is wise.

It is way smarter to use a PHP or other script to do the "heavy lifting" on a helper server, where there is unlimited memory for code to handle all if the SMTP protocol and queuing issues.

All those details take too long to explain to a novice user. I much prefer your answer "not possible". From a practical perspective, your answer is much better. :-)

Cheers.

agamar
 
Posts: 1
Joined: Thu Sep 22, 2011 9:15 pm

Re: Ethernet Shield: Can it send email?

Post by agamar »

Well, I have just rewritten some code for the arduino 3 different ways, and I still cannot send an email out via SMTP to my own local Exchange server. I can do it via telnet and it works fine. Anybody have any code that is known to work they could post?

User avatar
burpees_NH
 
Posts: 74
Joined: Wed Dec 15, 2010 5:31 pm

Re: Ethernet Shield: Can it send email?

Post by burpees_NH »

agamar wrote:Well, I have just rewritten some code for the arduino 3 different ways, and I still cannot send an email out via SMTP to my own local Exchange server. I can do it via telnet and it works fine. Anybody have any code that is known to work they could post?
I would suggest accepting the previously published suggestion:
.. have the Arduino "talk" to Exchange via HTTP (host a simple CGI/PHP script on Exchange, or actually "any" PC on your network).


... if you are really determined to use SMTP, note that you will never produce an RFC compliant SMTP library that fits in Arduino's limited memory.
You can conserve memory by ignoring SMTP rules, but then some mailservers will refuse your mail (as you noticed Exchange does).
Exchange can't possibly differentiate your SMTP demo from your Telnet test so it's something wrong in your code.

If you really want to do this the hard way, using SMTP, then of course the next step would be to compare your two SMTP conversations with Exchange. You'll also need to consult the SMTP RFCs so you can understand the requirements. Good luck.

Otherwise, a simple HTTP-->SMTP gateway (10 lines of PHP really) is the smart way to go. The script could run on Exchange, or on any workstation PC inside the same network.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”