ethernet shield send email or text msg

i am trying to send email from arduino ethernet shield with sample code from this site. i am connected but it keeps timing out. i think email server is not responding to me or i need to send my password for my email account then send email. or i could have a typo in code. my email provider uses port 465 and ssl with password protection but i am not sure what problem is. any suggestions would be great. i have att email and want to send text message to my phone on verizon.

#include <SPI.h>
#include <Ethernet.h>

byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip( 192, 168, 1, 100 ); //arduino static ip
IPAddress gateway( 192, 168, 1, 254 ); //my router
IPAddress subnet( 255, 255, 255, 0 );
//IPAddress dns( 208, 67, 220, 220 );

// change server to your email server ip or domain
//IPAddress server( 1, 2, 3, 4 );
char server = “my.email@sbcglobal.net”;
const int serverPort = 465;
//char server = “smtp-sl.vtext.com”;

EthernetClient client;

//---------------------------------------------------------
void setup()
{
Serial.begin(9600);
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
Ethernet.begin(mac, ip, gateway, subnet);
delay(2000);
Serial.println(F(“Ready. press e to send.”));
}

//----------------------------------------------------------
void loop()
{

byte inChar;
inChar = Serial.read();

if(inChar == ‘e’)
{
if(sendEmail()) Serial.println(F(“Email sent”));
else Serial.println(F(“Email failed”));
}
}

//----------------------------------------------------------
byte sendEmail()
{
byte thisByte = 0;
byte respCode;

if(client.connect(server, serverPort)) {
Serial.println(F(“connected”));
} else {
Serial.println(F(“connection failed”));
return 0;
}

if(!eRcv()) return 0;
Serial.println(F(“Sending helo”));

// change to your public ip
client.println(F(“helo my.public.ip.here”));

if(!eRcv()) return 0;
Serial.println(F(“Sending From”));

// change to your email address (sender)
client.println(F(“MAIL From: sender@email.com”));

if(!eRcv()) return 0;

// change to recipient address
Serial.println(F(“Sending To”));
client.println(F(“RCPT To: receiver@mail.com”));

if(!eRcv()) return 0;

Serial.println(F(“Sending DATA”));
client.println(F(“DATA”));

if(!eRcv()) return 0;

Serial.println(F(“Sending email”));

// change to recipient address
client.println(F(“To: You sender@email.com”));

// change to your address
client.println(F(“From: Me me@email.com”));

client.println(F(“Subject: test\r\n”));

client.println(F(“This is a test.”));

client.println(F("."));

if(!eRcv()) return 0;

Serial.println(F(“Sending QUIT”));
client.println(F(“QUIT”));

if(!eRcv()) return 0;

client.stop();

Serial.println(F(“disconnected”));

return 1;
}

byte eRcv()
{
byte respCode;
byte thisByte;
int loopCount = 0;

while(!client.available()) {
delay(1);
loopCount++;

// if nothing received for 10 seconds, timeout
if(loopCount > 10000) {
client.stop();
Serial.println(F("\r\nTimeout1"));
return 0;
}
}

respCode = client.peek();

while(client.available())
{
thisByte = client.read();
Serial.write(thisByte);
}

if(respCode >= ‘4’)
{
efail();
return 0;
}

return 1;
}

void efail()
{
byte thisByte = 0;
int loopCount = 0;

client.println(F(“QUIT”));

while(!client.available()) {
delay(1);
loopCount++;

// if nothing received for 10 seconds, timeout
if(loopCount > 10000) {
client.stop();
Serial.println(F("\r\nTimeout2"));
return;
}
}

while(client.available())
{
thisByte = client.read();
Serial.write(thisByte);
}

client.stop();

Serial.println(F(“disconnected”));
}

You can't use port 465 with the ethernet library. Only port 25. Both ports 465 and 587 require security that the ethernet library does not support.

BTW, I can and do send text messages to my cellphone from my Arduino ethernet shield.

Thanks but port 25 still doesnt work. it keeps timing out again. what is the server supposed to send back to me after i am connected? or do i need to sent my password for att email account?

You need to find the server that handles email for your domain, and use that as the server. If sbcglobal.net is your email domain, then this is the email server:

sbcglobal.net MX preference = 10, mail exchanger = mx2.sbcglobal.am0.yahoodns.net

char server[] = "mx2.sbcglobal.am0.yahoodns.com";

still results in a timeout error. confused.

Don't know if it will work,but "smtp.sbcglobal.net" answers port 25 here, but I don't have an email account there to send a test email to.

how do you check for an answer? i tried your server suggestion and it connects but times out here. i googled the sbcglobal.net stuff and tried other mail servers they showed and it seems they need port 465 and ssl and password. you stated 465 does not work with the arduino library so i seem to be stuck. i dont see any that work with port 25. even free smtp stuff sometimes blocks port 25 for spam reasons. is there anything else i can try unless there is a typo in the code. but it would make sense a email provider require this information so not just any appliance can use their stuff for free.

Don't know what to tell you. The server smtp.abcglobal.net returns this to me.

220 isp.att.net - Maillennium ESMTP/MULTIBOX frfwmhc02 #10

It may block you because of your ip if it determines you are in a non-commercial dhcp issued ip range. My ips are commercial static, so I don't have that problem.

can i try your mail server?

i made a email account on gmx.com cause they use port 25. and i looked up the mail server which is mx01.gmx.com. it still doesnt work and times out when i use my gmx email name as server in code but connects. and it locks up when i use that mail server in code as server and does not connect. i tried the other three mail servers and same thing. any suggestions?

It is possible your ISP is blocking tcp port 25 connection requests from any device on their network except to and from their email server. It may be a spam prevention measure.