Email send question.

Hi I’m trying to send an email from my Hotmail account to an gmail account using my ethernet shield. It is possible? This my code:
#include <SPI.h>
#include <Ethernet.h>

byte mac = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 };
IPAddress ip( 192, 168, 1, 107 );
IPAddress gateway ( 192, 168, 2, 1 );
IPAddress subnet ( 255, 255, 255, 0 );
IPAddress server (65,55,92,136);// hotmail smtp ip addres
int x= 5000;

EthernetClient client;

void setup()
{
delay(x);
Serial.begin(9600);
Ethernet.begin(mac,ip);
delay (x);
Serial.println (“connecting”);
if (client.connect (server,25)) {
Serial.println (“connected”);
client.println (“Hello @gmail.com”);
delay (x);
client.println (“Mail From:@gmail.com>”);
delay(x);
client.println (“RCPT To:@hotmail.com>”);
delay(x);
client.println (“DATA”);
client.println (“To:@hotmail.com”);
client.println (“Subject:Trial”);
client.println (“Espero que alla funcionado”);
client.println (“Quit”);
delay(x);
client.println();

} 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(;:wink:
;
}
}

I’m getting this in the serial monitor:

connecting
connected
220 SNT0-MC1-F36.Snt0.hotmail.com Sending unsolicited commercial or bulk e-mail to Microsoft’s computer network is prohibited. Other restrictions are found a
disconnecting.

You are not waiting for the server to respond. Here is an email send program with error checking. http://arduino.cc/forum/index.php/topic,102169.msg766795.html#msg766795

Same message

   client.println ("Hello @gmail.com");
    delay (x);
    client.println ("Mail From:@gmail.com>");

If you are connecting to hotmail, to send an email to google... then why are you talking to the hotmail server like it is google?

READ ONE POST UP! I don't know if it'll work with Hotmail. I tried to do the same thing using my Gmail account, until I found out that it won't work with Gmail. I wound up using the SMTP server, and thus the email account that my ISP gives me. Works perfect every time and hasn't failed on me once since I implemented it. In fact, my first sketch didn't have anything to stop it so before I could get to the Arduino to unplug it, my iPhone had close to 30 text messages. (I have the emails sent to my phone number @ my cellular provider so they come through as SMS messages.)

That was my bad copy/paste. In the program I have client.println ("Hello @gmail.com"); delay (x); client.println ("Mail From:@hotmail.com>"); And get the same error :0

Sorry for the stupid question,but how to I get the smtp ip address for gmail or hotmail? That I remember my ISP never give me any email accound.

Run this on your computer:

nslookup smtp.hotmail.com

This will throw an error:

client.println ("Mail From:@hotmail.com>");

When you send that, my email server returns something like "400 error: I don't take email from that malformed email address". I bet theirs does too. And with my code above, that message is displayed on the serial monitor before exiting with a fail message. It will not just exit.

add: Mine will also reject this: Mail from: user@NotMyDomain.com Mail to: anotheruser@alsoNotMyDomain.com

So does Hotmail and Gmail. It is called a "relay". Spammers use it if the server allows it, and is known as an "open relay".

The w5100 does not support a TLS connection that would allow that type connection to relay email.

smtp.hotmail.con doesn't work. I use smtp.live.com and use the ip address for the server. Use bot send and receiver email from hotmail and print this:

connecting connected 220 BLU0-SMTP410.phx.gbl Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Sat, 28 Apr 2012 11:15:42 -0700 530 5.7.0 Must issue a STAR disconnecting.

A couple of things. You probably need a smtp account with the web based mail services, and you will probably need to provide your user ID and password in the email to use the services. Gmail may have a moble smtp service. Check with your ISP about an email account. Most in the US provide free email accounts.

Ok...the program seems to work,but I don't receive the email. I change the port 25 to port 465 for gmail to send a email to hotmail. The answer in the serial monitor is this:

connecting connected Email send

disconnecting

Ok...the program seems to work,

What program are you refering to?

zoomkat:

Ok...the program seems to work,

What program are you refering to?

It is not mine. There are no reply messages from the server.

add: And even if it was, my code has no TLS encryption to connect with port 465. But then you would have known that using my code. One of the first replies from port 465 is "OK! Start your TLS", and neither of those programs can do that.

This code:

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

byte mac = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 };
IPAddress ip( 192, 168, 1, 107 );
IPAddress gateway ( 192, 168, 1, 1 );
IPAddress subnet ( 255, 255, 255, 0 );
IPAddress server (74,125,45,108);
int x= 5000;

EthernetClient client;

void setup()
{
delay(x);
Serial.begin(9600);
Ethernet.begin(mac,ip);
delay (x);
Serial.println (“connecting”);
if (client.connect (server,465)) {
Serial.println (“connected”);
client.println (“Hello @gmail.com”);
delay (x);
client.println (“Mail From:@gmail.com>”);
delay(x);
client.println (“RCPT To:@gmail.com>”);
delay(x);
client.println (“DATA”);
client.println (“To:@gmail.com”);
client.println (“Subject:Trial”);
client.println (“Espero que alla funcionado”);
Serial.println (“Email send”);
client.println (“Quit”);
delay(x);
client.println();

} 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(;:wink:
;
}
}

What, exactly, does this code do? for(;;) ;

There is a reason we harp on using the code tags!

That code won't send. Port 465 (and for Gmail it is 587) are not open connections. They both have security on them. You must authenticate with your Gmail user/password before sending anything.

  Serial.println ("connecting");
  if (client.connect (server,465)) {
    Serial.println ("connected");
    client.println ("Hello @gmail.com");
// server replies with "Hello. Start your TLS"
    delay (x);
// you don't start your TLS, so the server sends "400 error - If no TLS, then no send"
// you continue to attempt the send anyway, and it keeps replying with 400 errors.

Thanks for the tip PaulS.

Thanks SurferTim,but how can I authenticate my Gmail user and password on Arduino?