Arduino Uno Quick Start Manual page 207

Hide thumbs Also See for Arduino Uno:
Table of Contents

Advertisement

Serial.print("Connecting...");
50
-
if
(client.connect(_smtp_server, _port) <= 0) {
-
Serial.println("connection
-
}
else
{
-
Serial.println("connected.");
55
read_response(client);
-
if
(!_use_auth) {
-
Serial.println("Using no
-
send_line(client, "helo");
-
}
60
else
{
-
Serial.println("Using
-
send_line(client, "ehlo");
-
send_line(client,
-
send_line(client, _username);
65
send_line(client, _password);
-
}
-
send_line(
-
client,
-
"mail from: <"
70
);
-
send_line(
-
client,
-
"rcpt to: <"
-
);
75
send_line(client, "data");
-
send_line(client,
-
send_line(client,
-
send_line(client,
-
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 we ll walk through it step by step. First,
the
SmtpService
class encapsulates the SMTP server s IP address and its port.
These attributes are required in any case. In addition, we store a username
and a password in case someone s 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
failed.");
authentication.");
authentication.");
"auth
login");
+ email.getFrom() +
+ email.getTo() +
">"
"from: "
+ email.getFrom());
"to: "
+ email.getTo());
"subject: "
+ email.getSubject());
read_response
method starting on line 13. It waits for
www.it-ebooks.info
Emailing Directly from an Arduino
">"
191
report erratum
discuss

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Table of Contents