Salve a tutti! Sono nuovo di questo forum e spero di scrivere nella sezione giusta.. dopo invani tentativi per inviare una email con arduino sono giunto a quello corretto! Ho notato che sul forum e su internet manca un esempio funzionante aggiornato al 2013. Libero per esempio ha modificato le sue impostazioni di accesso e ora non è più possibile utilizzare l' esempio sul arduino.cc per inviare una mail con un account libero..o almeno..io non sono riuscito a farla funzionare. Virgilio è rimasto funzionante. Pertanto invito tutti coloro che vogliono iniziare un progetto con questa funzione di basarsi su questo esempio. funzionante.
#include <SPI.h>
#include <Ethernet.h>
// Local network configuration:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x23, 0x5D }; //MAC DELLA VOSTRA RETE
byte ip[] = { Y, Y, Y, Y }; // INSERITE IL VOSTRO IP NELLA RETE LOCALE ASSOCIATO AD ARDUINO
// Login data:
String UserName64 = "XXXXXXX";
String Password64 = "XXXXXXX";
byte server[] = { 62, 211, 72, 20 }; // SMTP server VIRGILIO
String ServerName = "virgilio.it";
// Mail data:
String Sender = "XXXXXXX@virgilio.it";
String Recipient = "XXXXXXX"; // Indirizzo qualsiasi di posta elettronica
String Subject = "Messaggio inviato da Arduino!";
String Body = "Testo del messaggio\nsu piu'\ndi una riga.";
int time = 1000;
int wait = 1000;
String ServerResponse="";
EthernetClient client;
void setup()
{
Serial.begin(9600);
Serial.println("Program started, waiting for router...");
delay(time); /* allow the router to identify the Arduino before the Arduino connects to the internet */
Serial.println("Starting network module...");
Ethernet.begin(mac, ip);
delay(2000);
Serial.println("connecting...");
if (client.connect(server, 25)) {
Serial.println("connected");
SendMsg("EHLO " + ServerName); /* say hello*/
SendMsg("AUTH LOGIN ");
SendMsg(UserName64); /* Username*/
SendMsg(Password64); /* Password */
SendMsg("MAIL From:<" + Sender +">"); /* identify sender */
SendMsg("RCPT To:<" + Recipient + ">"); /* identify recipient */
SendMsg("DATA");
SendMsg("To: " + Recipient); /* recipient in message header */
SendMsg("From: " + Sender); /* seder name in message header */
SendMsg("Subject: "+ Subject); /* insert subject */
SendMsg(""); /* empty line */
SendMsg(Body); /* insert body */
SendMsg(""); /* empty line */
SendMsg("."); /* end mail */
SendMsg("QUIT"); /* terminate connection */
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( ; ; )
;
}
}
void GetResponse() {
if (client.available()) {
char c = client.read();
while (client.available()) { // Store command char by char.
ServerResponse +=c;
c = client.read();
}
Serial.println("<<<" + ServerResponse);
ServerResponse="";
}
}
void SendMsg(String m) {
client.println(m);
Serial.println(">>>" + m);
delay(wait); /* wait for a response */
GetResponse();
}
Per poter utilizzare questo esempio dovete convertire su questi siti ( usatene uno per la password e uno per l'Email , ma non entrambi sullo stesso per motivi di sicurezza) le vostre credenziali di login : ID ( nome@virgilio.it) pass ( password dell'account).
Base64 Online - base64 decode and encode e webnet77.com
webnet77.com
Per conoscere invece il vostro Mac Address seguite queste istruzioni: https://forms.swlaw.edu/swlawforms/findmacaddress.htm#ipconfig
per qualsiasi info contattatemi a fabiogrs93@live.com
Ciao a tutti spero di essere di aiuto =)
[EDIT] aggiunto CODE-Tag. Uwe[/EDIT]