We send our username and encode it using Base64, too. The SMTP server’s
reply is UGFzc3dvcmQ6 (“Password:”), so we send our password (encoded
using Base64).
Note that although Base64 data looks cryptic, it’s not encrypted at all. It’s as
insecure as plain text, and there are software developers who can read Base64
data as quickly as regular text. You can find countless Base64 converters on
the Web, and there’s a Base64 library for nearly every programming language.
After the authentication succeeds, we tell the server that we’d like to send an
email using
MAIL FROM:
. The email address we provide with this command will
be used by the server in case our email bounces back. Note that the server
sends back a response line for every request. These responses always start
with a three-digit status code.
The
RCPT TO:
command sets the recipient’s email address. If you’d like to send
an email to more than one recipient, you have to repeat the command for
each of them.
With the
DATA
command, we tell the server that we now start to transmit the
email’s attributes. Email attributes are mainly a list of key/value pairs where
key and value are delimited by a colon. So in the first three lines, we set the
attributes “from,” “to,” and “subject,” and they all have the meaning you’d
expect when sending an email.
You separate the email’s body from the attributes using a blank line. To mark
the end of the email body, send a line containing a single period. Send the
QUIT
command to end the session with the SMTP server.
You should find a new email in your inbox or in your spam folder. If not, try
another SMTP server first. Things can still go wrong, and although simple in
theory, SMTP can be a complex beast in practice. SMTP servers often return
helpful error messages that might help you quickly solve your problem.
If you want to give your current SMTP server a try, you have to find out its
address first. Open a terminal and enter the following:
maik> nslookup
> set type=mx
> gmail.com
Server: 192.168.2.1
Address: 192.168.2.1#53
Non-authoritative answer:
gmail.com mail exchanger = 5 gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 20 alt2.gmail-smtp-in.
> exit
report erratum • discuss
Emailing from the Command Line • 187
www.it-ebooks.info