EasyManuals Logo

Arduino Pro Mini User Manual

Arduino Pro Mini
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #207 background imageLoading...
Page #207 background image
Serial.print("Connecting...");
50
-
if (client.connect(_smtp_server, _port) <= 0) {
-
Serial.println("connection failed.");
-
} else {
-
Serial.println("connected.");
55
read_response(client);
-
if (!_use_auth) {
-
Serial.println("Using no authentication.");
-
send_line(client, "helo");
-
}
60
else {
-
Serial.println("Using authentication.");
-
send_line(client, "ehlo");
-
send_line(client, "auth login");
-
send_line(client, _username);
65
send_line(client, _password);
-
}
-
send_line(
-
client,
-
"mail from: <" + email.getFrom() + ">"
70
);
-
send_line(
-
client,
-
"rcpt to: <" + email.getTo() + ">"
-
);
75
send_line(client, "data");
-
send_line(client, "from: " + email.getFrom());
-
send_line(client, "to: " + email.getTo());
-
send_line(client, "subject: " + email.getSubject());
-
send_line(client, "");
80
send_line(client, email.getBody());
-
send_line(client, ".");
-
send_line(client, "quit");
-
client.println("Disconnecting.");
-
client.stop();
85
}
-
}
-
};
-
-
#endif
90
Admittedly, this is a lot of code, but well walk through it step by step. First,
the
SmtpService
class encapsulates the SMTP servers IP address and its port.
These attributes are required in any case. In addition, we store a username
and a password in case someones going to use an authenticated connection.
To communicate with an SMTP server, we have to read its responses, and we
do that using the private
read_response
method starting on line 13. It waits for
report erratum discuss
Emailing Directly from an Arduino 191
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino Pro Mini and is the answer not in the manual?

Arduino Pro Mini Specifications

General IconGeneral
BrandArduino
ModelPro Mini
CategoryMotherboard
LanguageEnglish

Related product manuals