Error sending email using Ethernet board

I just followed the comments in the forum How to access smtp.gmail.com or other to send email - Networking, Protocols, and Devices - Arduino Forum
I am still not able to send an email.
Here is what I did

#include <Ethernet.h>

#include <SPI.h>

byte mac[] = { 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- }; //provided my Ethernet mac
byte ip[] = { xx, xx, x, xx }; // lan ip
byte gateway[] = { xx, xx, xx, xx }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte smtp[] = { 207,58,142,213 }; // ip of www.smtp2go.com

EthernetClient client;

void setup()
{
Ethernet.begin(mac, ip,gateway,subnet);
//server.begin();
Serial.begin(9600);

delay(1000);

Serial.println("connecting...");

// EthernetClient client = server.available();

if (client.connect(smtp,25)) {
Serial.println("connected");
client.println("EHLO kltan");
client.println("AUTH LOGIN");
client.println("smtp username encode");
client.println("smtp password encode");
client.println("MAIL FROM:abc@gmail.com");
client.println("RCPT TO:abc@gmail.com");
client.println("DATA");
client.println("abc@gmail.com");
client.println("to:abc@gmail.com");
client.println("SUBJECT: Testing subject to arduino ethernet shield");
client.println();
client.println("This is the line body.");
client.println("This is another line of the body.");
client.println(".");
client.println(".");
client.println("QUIT");
} else {
Serial.println("connection failed");
}
}

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

That is old code and it doesn't wait for a reply.
I use this, and it works with a simple mailserver.
http://playground.arduino.cc/Code/Email

Thanks
I used the code in the link. I provided all the network configuration.
I used server= smtp.gmail.com and server port as 25. I am still not able to send an email.
Is there anything which I could be missing in terms of configuration to send email via Gmail?

I get this output.

connected
220 mx.google.com ESMTP ac5sm48600361pbc.37 - gsmtp
250 mx.google.com at your service
530 5.7.0 Must issue a STARTTLS command first. ac5sm48600361pbc.37 - gsmtp
221 2.0.0 closing connection ac5sm48600361pbc.37 - gsmtp
disconnected
Email failed

Any idea?

It seems that a STARTTLS is needed, which is a secure protocol. You need a simpler mail server.

Ohh thanks.
Still any idea on the simpler server i should go ahead with ?

I don't know, perhaps most of the larger mail server providers use secure login.

My own local internet provider is still able to use plain SMTP, but they know that I'm a client of them ofcourse.

According to this it should be possible to make a "AUTH LOGIN PLAIN" login.
http://www.ndchost.com/wiki/mail/test-smtp-auth-telnet
But you still have to find a mail server that supports that, like http://www.gmx.com

Thanks alot
I used my university mail server and it worked
:slight_smile: