It seems pretty easy to connect to a SMTP server with a socket connection.
Here is an example for the arduino, should be easy to port over to mbed: You do need to know your mail server address if you want this to work
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte server[] = { 64, 233, 187, 99 }; // Mail server address MODIFY THIS FOR THE TARGET DOMAIN's MAIL SERVER
Client client(server, 25);
void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("EHLO MYSERVER");
client.println("MAIL FROM:");
client.println("RCPT TO:");
client.println("DATA");
client.println("SUBJECT: This is the subject");
client.println();
client.println("This is the body.);
client.println("This is another line of the body.");
client.println(".");
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(;;)
;
}
}
Here's the commands you need to send to the server with the socket connection: http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol#SMTP_transport_example
But if you have a webserver you could make a PHP script which the mbed would call, and then it sends the email. <- That's what I'm doing
The PHP could be as simple as:
<?php
$to = "recipient@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
Hello,
I am wondering if antyone knows of a way to set up a simple smtp client on an mbed?
It could be used to shoot an email upon some kind of trigger- door open etc..
thanks!