Go Down

Topic: Need help getting Arduino to send email (Read 17 times) previous topic - next topic

GordonEndersby


Im with Virgin previously blueyonder here in the UK and they want authentication for pop and smtp.

Gordon

Mark Bramwell


I understand the need for authentication for pop, or auth for smtp if you are not on your ISP's ip range but if auth is required for the arduino then it becomes a complex problem.  Authenticated SMTP is more than just sending a plain-text password.

do a wiki of auth-smtp for more details.

kg4wsv

The arduino cannot do TLS or SSL.  Those are too much to expect from an 8 bit microcontroller.  (Of course as soon as I say that, follower will find an example of someone who has already done it. :) )

See if your ISP will allow a direct unauthenticated unencrypted port 25 SMTP connection.

-j


eguld

Thank you guys it is now complete!!! I am submitting it for reference if anyone else would like to play around with sending emails.  The *'s are used to hide personal data that will need to be inputted to make the program function.

[glow]/*
SEND AN EMAIL WITH ARDUINO

This code was created by modifying the connect example from arduino.cc and with the help of the YABB forums and their very helpful members.
This code sends an email to any email address and then disconnects.  It will also print on screen (in the serial monitor) the data the server sends the Arduino.  Make sure to replace all the *'s with your own information.
*/

#include <Ethernet.h>

byte mac[] = { 0x*, 0x*, 0x*, 0x*, 0x*, 0x* }; // Arduino's artificial mac address
byte ip[] = { *, *, *, * }; // my ip
byte server[] = { *, *, *, * }; // my smtp server ip
int time = 5000;
int wait = 2000;


Client client(server, 25);

void setup()
{
 delay(time);
 
 Ethernet.begin(mac, ip);
 Serial.begin(9600);
 
 delay(1000);
 
 Serial.println("connecting...");
 
 if (client.connect()) {
                        Serial.println("connected");
   
                        client.println("HELO itismeletschat"); /* say hello (statement after helo is needed but irrelevant)*/
                          delay(wait); /* wait for a response */

                        client.println("MAIL From: eguld@youremail.com"); /* identify sender, this should be the same as the smtp server you are using */
                          delay(wait); /* wait for a response */

                        client.println("RCPT To: guld.enrico@therecipientsmail.com"); /* identify recipient */
                        delay(wait); /* wait for a response */

                        client.println("DATA");
                          delay(wait); /* wait for a response */
 
                        client.println("To: guld.enrico@therecipientsmail.com"); /* identify recipient */
                        client.println("Subject: You Have Mail!!"); /* insert subject */

                        client.println("Please let me know it worked!!!"); /* insert body */
                        client.println("."); /* end email */
                 
                        client.println("QUIT"); /* terminate connection */
                         delay(wait); /* wait for a response */

 
   client.println();
   
 } else {
   Serial.println("connection failed");
 }
}

void loop()
{
 while (client.available()) {
   char c = client.read();
   Serial.print(c);
 }
 
 if (!client.connected()) {
   Serial.println();
   Serial.println("disconnecting.");
   client.stop();
   for(;;)
     ;
 }
}[/glow]

Thanks again,

-Enrico

follower

Quote
The arduino cannot do TLS or SSL.  Those are too much to expect from an 8 bit microcontroller.  (Of course as soon as I say that, follower will find an example of someone who has already done it. :-) )

Is that going to be your new game? :-)

The closest I've discovered in my wanderings are the SHA-1 and HMAC-SHA-1 implementations I linked to from my Arduino and IRC page.

--Phil.

Go Up