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( ;; )
;
}
}