this is the code which i have used...
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 };
IPAddress ip( 192, 168, 1, 35 );
IPAddress gateway( 192, 168, 1, 1 );
IPAddress subnet( 255, 255, 255, 0 );
// gmail.com email server
IPAddress server(74,125,71,26);
EthernetClient client;
void setup()
{
Serial.begin(9600);
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
delay(2000);
Serial.println("Ready. Press 'e' to send");
}
void loop()
{
byte inChar;
inChar = Serial.read();
if(inChar == 'e')
{
if(sendEmail()) Serial.println("Email sent");
else Serial.println("Email failed");
}
}
byte sendEmail()
{
byte thisByte = 0;
byte respCode;
Serial.println("start connecting");
if (client.connect(server,25)) {
Serial.println("connected");
} else {
Serial.println("connection failed");
return 0;
}
if(!eRcv()) return 0;
// change this ip to your public ip
client.write("helo 115.118.170.24\r\n");
if(!eRcv()) return 0;
// change this
client.write("MAIL From: sathi.rska@gmail.com\r\n");
if(!eRcv()) return 0;
// change this
client.write("RCPT To: ashokkumar.sp7@gmail.com\r\n");
if(!eRcv()) return 0;
client.write("DATA\r\n");
if(!eRcv()) return 0;
//change this
client.write("To: You ashokkumar.sp7@gmail.com\r\n");
// change this
client.write("From: Me sathi.rska@gmail.com\r\n");
client.write("Subject: Arduino email test\r\n");
client.write("\r\n");
client.write("This is from my Arduino!\r\n");
client.write("This is another line of the body.\r\n");
client.write(".\r\n");
client.write(".\r\n");
if(!eRcv()) return 0;
client.write("QUIT\r\n");
if(!eRcv()) return 0;
client.stop();
Serial.println("disconnected");
return 1;
}
byte eRcv()
{
byte respCode;
byte thisByte;
while(!client.available()) delay(1);
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;
client.write("QUIT\r\n");
while(!client.available()) delay(1);
while(client.available())
{
thisByte = client.read();
Serial.write(thisByte);
}
client.stop();
Serial.println("disconnected");
}
is theri is any problem in this code..