To send an e-mail with EMAilSender, you can work with SendGrid. (https://sendgrid.com/en-us)
– create an account (free up to 100 mails per day).
install an application on the mobile phone for 2-level authentication
– create a SMTP Relay API key (full access)
copy the key and all your account information.
at the beginning of the code, don’t forget to enter :
—————————————————
#include <Arduino.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EMailSender.h>
#define DEFAULT_EMAIL_NETWORK_TYPE_ARDUINO NETWORK_W5100 //If you’re using a schield W5100.
byte mac[6] = { 0x** 0x**, 0x**, 0x**, 0x**, 0x** }; // Your Adress Mac
IPAddress ip(192, 168, *, ***); // Your Address IP
// apikey signals that we’re going to send a code related to an api module
// your_password_apikey is the password given by Sendgrid when requesting an SMTP Relay key.
// your_mail is the Sendgrid login address.
// You must use 587 as port
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
// while (!Serial) {}
delay(2000);
Serial.println(“Port série ok”);
// start the Ethernet connection:
pinMode(4, OUTPUT); // config for shield W5100 on MEGA2560
digitalWrite(4, HIGH); // config for shield W5100 on MEGA2560
if (Ethernet.begin(mac) == 0) {
Serial.println(“Failed to configure Ethernet using DHCP”);
while(1);
}
Serial.print(“Addresse IP “);
Serial.println(Ethernet.localIP());
EMailSender::EMailMessage message;
message.subject = “Test”;
message.message = “This indicates a reboot of the arduino”;
EMailSender::Response resp = emailSend.send(“address@****.***”, message);
Serial.print(“Status: “);
Serial.println(resp.desc);
void loop()
{
if(Serial.read() == ‘S’) {
if(sendEmail_1()); // to send the mail
}
}
byte sendEmail_1() {
EMailSender::EMailMessage message;
message.subject = “Your mail title”;
message.message = “Your information message”;
EMailSender::Response resp = emailSend.send(“address@****.***”, message);
Serial.print(“status: “);
Serial.println(resp.desc);
}
——————————————————————
Just incorporate this sketch into your own and have fun!
I had to search a lot of forums to find a simple way to send email alerts from my Arduino system. (I have information coming from my heater, a pump, etc …).
The EMailSender and SendGrid combination is the simplest.
You need to create a SendGrid account and take the free option.
You will need a confirmation app on your mobile phone.
then create an api (relay).
Save your codes, they won’t be visible after they’ve been created.
that should do it.
see : https://sendgrid.com/en-us/blog/smtp-relay-service-basics
This reply was modified 8 months, 2 weeks ago by Jules.
it’s a simple 2-level confirmation …
(mail + password) and mobile number
Sorry, but I don’t think we can call each other. I live in Belgium and I don’t understand enough English to hold a conversation. Writing is one thing, but conversation is another…
So Actually i did everything as told and my code is the same as yours i did 2FA on the sendgrid and i confirmed my mobile number too.
– I also did a Sender Authentication From where to where it needs to go // is this necessecary?
– I used the SMPT Relay where i made an api key and i used it for the apikey and apikey passowrd // is this correct?
– When i send a mail through arduino the Intnernet is working because i can see that it makes TCP connection to Sendgrid servers.
– Im sending from an Outlook Email to a Gmail Email and i dont know if that is right.
-do you need to pay sendgrid at anypoint because i want to use it for my self and send some email time to time ?
Hee i will put my Code (i want it to keep it very simple) maybe you can see any mistakes 🙂
#include <Ethernet.h>
//#define DEFAULT_EMAIL_NETWORK_TYPE_ARDUINO NETWORK_W5100
#include <Arduino.h>
#include <SPI.h>
#include <EMailSender.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EMailSender emailSend("apikey", "apikey-psw", "<my sendgrid email>", "smtp.sendgrid.net", 587);
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
// while (!Serial) {}
Serial.println("Starting!");
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
while(1);
}
Serial.print("IP address ");
Serial.println(Ethernet.localIP());
EMailSender::EMailMessage message;
message.subject = "This is a Test";
message.message = "Its a Test";
EMailSender::Response resp = emailSend.send("the email i want the maessage to go", message);
Serial.println("Sending status: ");
Serial.println(resp.status);
Serial.println(resp.code);
Serial.println(resp.desc);
}
void loop()
{
Serial.begin(9600);
Serial.println("Starting!");
}
Thank you because im trying for a Week to get this working 🙂
This reply was modified 8 months, 1 week ago by erjon.
// apikey remains apikey
// apikey-psw is the key given by SendGrid (64 characters)
// snedgridmail ==> do not put the < >
// ERROR : EMailSender::Response resp = emailSend.send(“the email i want the maessage to go”, message);
ok => EMailSender::Response resp = emailSend.send(“recipient@mail.***”, message);
make these changes and it should work
SendGrid is normally free for non-intensive personal use
since you didn’t put a destination address, it couldn’t go … “recipient@mail.***”
Maintaining a repository (or site or forum) is a lot like tending to a garden - it requires constant care and attention to keep it thriving. If you're a skilled gardener (or coder!) and want to help keep our repository blooming, we'd love to have you on board! We're also looking for talented writers and forum moderators to help us grow our community. Interested in joining our team? Don't hesitate to reach out and let us know how you can contribute!
Are you a fan of electronics or programming? Share your knowledge with others, write a simple tutorial or how to make a great project Contact me: share_your_ideas@mischianti.org
The content displayed on this website is protected under a CC BY-NC-ND license. Visitors are prohibited from using, redistributing, or altering any content from this website for commercial purposes, including generating revenue through advertising. Any unauthorized use is a violation of the license terms and legal action may be taken against individuals or entities found to be in violation.
You must also provide the link to the source.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.