Hardware Reference
In-Depth Information
Sending e-mail updates
With the right software, it's possible to compose e-mails, complete with attachments,
directly from the command line. We'll be using an excellent application written in
Perl called smtp-cli . It's the perfect tool to add e-mail capabilities to your shell
scripts. Follow these steps to get started with smtp-cli:
1.
First we need to install some dependencies:
pi@raspberrypi ~ $ sudo apt-get install libio-socket-ssl-perl
libdigest-hmac-perl libterm-readkey-perl libmime-lite-perl
libfile-libmagic-perl libio-socket-inet6-perl --no-install-
recommends
2.
Now we download smtp-cli and put it in a suitable location:
pi@raspberrypi ~ $ sudo wget http://www.logix.cz/michal/devel/
smtp-cli/smtp-cli-3.6 -O /usr/bin/smtp-cli
3.
Finally, we have to give the application executable permissions:
pi@raspberrypi ~ $ sudo chmod +x /usr/bin/smtp-cli
To send out e-mails, we need to have access to an SMTP server (sometimes, simply
called mail server). The common alternatives are to use either an SMTP server run by
your Internet service provider, or servers connected to e-mail services such as Gmail
or Yahoo Mail. Take a look at the account settings of your regular e-mail client to
figure out the details needed to send out e-mail.
Let's try to send an e-mail using your Internet service provider:
pi@raspberrypi ~ $ smtp-cli --verbose --server smtp.myisp.com:25 --from
"Secret Agent <secret.agent@myisp.com>" --to "Fellow Peer <fellow.peer@
agenthq.com>" --subject "Testing" --body-plain "This is a test email"
The previous example showed the bare minimum options required to send an e-mail;
let's break down each option:
--server : Here we specify the SMTP server address and port that you
would need to find out from your Internet service provider. Port 25 is the
standard for SMTP but port 587 is also common for servers accepting the
TLS encrypted communication.
--from : Your name and e-mail address goes here. Note that many servers
will happily accept any address as the sender. Some of your less tech-savvy
friends might be shocked to receive an e-mail from bill.gates@microsoft.
com for example.
--to : The name and e-mail address of the recipient.
--subject : The subject line for the e-mail.
 
Search WWH ::




Custom Search