Et oui la question qui tue ! Comment envoyer un email à partir de l'arduino ? >< J'ai lu des trucs à propos du fait qu'il fallait utiliser les commande telnet, sauf que telnet c'est dépasse et n'importe quel email envoyé depuis est considéré comme spam pour le serveur. Ainsi il n'arrive même pas au destinataire !
Avec un Ethernet Shield, utiliser la méthode GET ou POST pour envoyer une information sur une page web que tu auras préalable fait. Tu as un exemple dans Ethernet > WebClient qui fait comme une requête par méthode GET vers le site Google. Pour ma part j'ai réussi à entrer des informations dans une base de donnée alors je pense que de faire un envoie de courriel ne devrais pas être bien difficile
poour faire vite fait tu envoies à une page (méthode post) http://ton_site_web.com/send_mail.php?mail=1
et dans ton fichier un code du genre :
<html>
<body>
<?php
if(POST[mail] == "1"){
$destinataire = "testemail@toutestfacile.com";
echo "Ce script envoie un mail à $destinataire";
mail($destinataire, "test email 1", "merci pour ton tutorial");
}
?>
</body>
</html>
j'ajouterais même que c'est certainement la meilleur méthode car tu passeras par un site internet herberger sous un nom de domaine donc tu risques beaucoup moins que ton courriel soit considérer comme SPAM.
Bonjour,
La meilleur méthode c'est d'utiliser le protocole smtp avec le serveur smtp de son fournisseur d’accès internet si la page est envoyée via leurs serveurs et sous format html il est pas reconnu comme spam.
Pour mettre en place le protocole smtp effectivement on peut utiliser telnet/netcat.
Ou sur l'arduino de simple .println("")
Le protocole smtp :
N'existe-t-il pas un risque que le message envoyé depuis l'arduino directement soit considérer comme un spam ? Par expérience les boites courriel, gmail, yahoo etc... sont très très sensible, alors envoyé depuis l'arduino.. tu risques vite de retrouver tes messages dans la boîte à SPAM.
En même temps si c'est pour faire parvenir le courriel toujours à la même adresse il te suffira (si il tombe dans la boite à spam) d'aller voir et de l'accepter comme un message sans risque et ainsi les suivants seront bien reçu dans ta boite courriel Après si l'adresse change régulièrement la c'est plus embêtant.
Voilà mon premier code qui fonctionne ^^ mais elle ne donne aucun sujet du mail et encore mieux, l'email est sans expéditeur ><
Une petite aide à nouveau ? =)
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,30 };
byte server[] = { 80,12,242,86 }; // Orange smtp
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 25);
void setup() {
// start the Ethernet connection:
Ethernet.begin(mac, ip);
// start the serial library:
Serial.begin(9600);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect()) {
Serial.println("connected"); // Make a HTTP request:
delay(2000);
char c = client.read();
Serial.print(c);
client.println("HELO XXXXXXXXXX");
char d = client.read();
Serial.print(d);
delay(2000);
client.println("MAIL FROM:XXXXXX@orange.fr");
delay(500);
client.println("RCPT TO:XXXXXX@gmail.com");
delay(500);
client.println("DATA");
delay(500);
client.println("BEUG ARDUINO");
delay(500);
client.println(".");
delay(500);
client.println("");
delay(5000);
client.println("quit");
delay(500);
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
/* if (client.available()) {
char c = client.read();
Serial.print(c);
}
*/
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;;)
;
}
}
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,30 };
byte server[] = { 80,12,242,52 }; // Orange
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 25);
void setup() {
// start the Ethernet connection:
Ethernet.begin(mac, ip);
// start the serial library:
Serial.begin(9600);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect()) {
Serial.println("connected"); // Make a HTTP request:
delay(2000);
char c = client.read();
Serial.print(c);
client.println("HELO xxxxxxx");
char d = client.read();
Serial.print(d);
delay(2000);
client.println("MAIL FROM:xxxxxxx@orange.fr");
delay(500);
client.println("RCPT TO:xxxxxxx@gmail.com");
delay(500);
client.println("DATA");
delay(500);
client.println("From: Arduino <xxxxxxxxx@orange.fr>");
delay(100);
client.println("Subject: Arduino Erreur");
delay(100);
client.println("To: xxxxxx@gmail.com");
delay(100);
client.println("");
delay(100);
client.println("BEUG ARDUINO");
delay(100);
client.println(".");
delay(500);
client.println("");
delay(5000);
client.println("quit");
delay(500);
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
/* if (client.available()) {
char c = client.read();
Serial.print(c);
}
*/
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;;)
;
}
}