send email with ethernet shield

can any one tell me why this is happening PLEASE

/*
   Email client sketch for IDE v1.0.1 and w5100/w5200
   Posted December 2012 by SurferTim
*/

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

// this must be unique
byte mac[] = { 
  0x00, 0x02, 0x00, 0x08, 0x00, 0xf2 };
IPAddress ip(192,168,0, 7);
IPAddress gateway(192,168,0, 1);
IPAddress subnet(255, 255, 255, 255);

// change server to your email server ip or domain
// IPAddress server( 205,188,157,37 );
//char server[] = "barrdav6@aol.com";
char server[] = "smtp.aol.com";
EthernetClient client;

void setup()
{
  Serial.begin(9600);
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  Ethernet.begin(mac, ip, gateway, 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,25)) {
    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 90.204.237.173"));

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

// change to your email address (sender)
  client.println(F("MAIL From: <barrdav7@aol.com>"));

  if(!eRcv()) return 0;

// change to recipient address
  Serial.println(F("Sending To"));
  client.println(F("RCPT To: <barrdav6@aol.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 <barrdav7@aol.com>"));

// change to your address
  client.println(F("From: Me <barrdav6@aol.com>"));

  client.println(F("Subject: Arduino email test\r\n"));

  client.println(F("This is from my Arduino!"));

  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\nTimeout"));
      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\nTimeout"));
      return;
    }
  }

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

  client.stop();

  Serial.println(F("disconnected"));
}

hope someone can help thanks

arduino email.png

I don't know the current policies that AOL has on email acceptance but I'd guess that they only accept emails if the sender authenticated itself (google for SMTP Auth). SurferTim's email client just sends the mail to an SMTP server that's accepting all email from the Arduino's IP address.
Because you're sending directly to the SMTP server of AOL, you might think that it should nevertheless accept your email. But the MX record of aol.com (that's where a real mail server would send mails for aol.com to) doesn't point to smtp.aol.com but to mailin-0_.mx.aol.com (where the _ is digit 1-4) and even there the restriction you saw in the SMTP conversation (valid DNS reverse record) may apply. Sending emails isn't as easy as it was 20 years ago, say thank you to the greedy spammers out in this world.

thanks for replying. So if i setup an hot mail account would this work ?

i have tried with my gmail account and a get

“530 5.7.0 Must issue a STERTTLS comand first. qc10sm8407064wic.9 - gsmtp”

as the gmail image shows PLEASE SOMEONE HELP !!!

gmail.png

What's your internet provider? It should have an outgoing SMTP server for you.
If your provider also enforces SMTP Auth post it here in the forum (not your credentials!) and we'll enhance TimSurfer's sketch to also do SMTP Auth. I seriously hope that every public email provider (as gmail, hotmail and the like) doesn't let you just send email over their servers without checking at least the knowledge of account parameters.

If you do not have a commercial account with a domain, AOL and some others will not accept email from that ip. The email server does a reverse dns lookup on your ip. If it does not resolve to a domain server, the email server refuses it. I think Gmail servers do the same.

Try pylon's suggestion about your local ISP's email server as a relay.

edit: This is why my email sketch reads and displays the server response. Otherwise, you would have not a clue why it was being rejected.

Hi,
I also would like to send an email directly from the Arduino. I can send one using sndmail on a Pc, but I really don’t want to have a pc connected all the time to the ardunio.

I seem to be getting to the server ( smtp.aol.com:587 ) as I get a connected message, but then I get a timeout. I’m guessing that it’s not getting thru the authorization process since this sketch doesn’t send anything for that.
This is the sndmail batch job I use. on a Pc which works fine. Is there a way to send the user name and password…
sendEmail -f pumpmck@aol.com ^
-t pumpmck@aol.com ^
-s smtp.aol.com:587 ^
-xu pumpmck ^
-xp mypassword ^
-u “Home Temperature” ^
-m “Hello, this is test2 email.”

-u is subject
-m is message
-xu USERNAME username for SMTP authentication
-xp PASSWORD password for SMTP authentication