Pages: 1, 2
I had a student from the old Soviet Union. She was quite bright; in her
homeland she used to program directly into machine language, and I do mean
0s. Her father-in-law was one of the moon
drivers for the Luna moon
missions. Another interesting habit of hers was to email her husband by
telnet session into both the SMTP and POP servers.
SMTP and POP3 are among a number of protocols that use a pseudo-English language. The original intention was to allow anybody to interface with a server directly and carry out a communication session — to send and receive email.
Just for the fun of it, I replicated what she did in a
telnet session on my
Here's a subset of SMTP:
||Initiate communication with SMTP server|
||Specify who is sending the email|
||Specify who is to receive the email|
||Specify data of the email (any number of lines)|
||A period alone specifies the end of the email|
||Close the connection|
Here's a sample SMTP session from my own machine. After I've connected, all of the SMTP server's responses start with numeric codes.
[bernier@wolf bernier]$ telnet localhost 25 Trying 127.0.0.1... Connected to wolf (127.0.0.1). Escape character is '^]'. 220 localhost.localdomain; ESMTP Thu, 6 Mar 2003 17:57:01 -0500 helo localhost 250 localhost.localdomain Hello wolf [127.0.0.1], pleased to meet you mail from: bernier@localhost 250 2.1.0 bernier@localhost... Sender ok rcpt to: firstname.lastname@example.org 250 2.1.5 email@example.com... Recipient ok data 354 Enter mail, end with "." on a line by itself subject; I'm hungry, send pizza Please send me one large pepperoni all dressed. Don't forget the pineapples! . 250 2.0.0 h26N3hs18884 Message accepted for delivery quit 221 2.0.0 localhost.localdomain closing connection Connection closed by foreign host.
Here's a subset of the POP3 protocol:
||Identify the user|
||Type in the password|
||Lists all emails available|
||Retrieval of a given email|
||Mark a given email for deletion upon clean logout|
||Close the session cleanly|
telnet session from my ISP's POP server:
bash-2.05$ telnet localhost 110 Trying 127.0.0.1... Connected to localhost.localdomain Escape character is '^]'. +OK InterMail POP3 server ready. user bernier +OK please send PASS command pass 1234 +OK bernier is welcome here list +OK 1 messages retr 2 +OK 767 octets Return-Path: <firstname.lastname@example.org> Received: from localhost.localdomain ([220.127.116.11]) by tomts5-srv.bellnexxia.net (InterMail vM.5.01.04.19 201-253-122-122-119-20020516) with ESMTP id <20030307030259.NLJD29897.email@example.com> for <firstname.lastname@example.org>; Thu, 6 Mar 2003 22:02:59 -0500 Received: (from bernier@localhost) by localhost.localdomain (XXX/linuxconf) id h2730mA01858 for email@example.com; Thu, 6 Mar 2003 22:00:48 -0500 Date: Thu, 6 Mar 2003 22:00:48 -0500 From: root <firstname.lastname@example.org> Message-Id: <200303070300.h2730mA01858@localhost.localdomain> To: email@example.com Subject: I'm hungry send pizza Please send me one large pepperoni all dressed. Don't forget the pineapples! .
telnet is the best way to figure out why email doesn't work. You will
be informed the exact reason from the server why there's a failure, unlike the
error messages that you get from clients such as, for example, Microsoft outlook.
Many help-desk technicians receive some form of training in the POP and SMTP
This is such a useful little trick. We had an employee that worked from home
on a dial-up connection. Every Friday night he had to leave his machine on so
some automated tasks could take place. His machine was therefore configured to
send an email with his IP address about 10 minutes prior to the maintenance
mode starting. The
cron job on his machine consisted of a one-line command
similar to the one below. (Be careful about the use of
number of digits for the IP address range was already known, so we were able to
specify the address length exactly.)
echo `/sbin/ifconfig | grep -A 1 eth0 | grep inet \ | cut -c21-33 ` | mail -s employeeX firstname.lastname@example.org
Have you ever used
Both utilities are designed to encode binary information to the ASCII character
shar utility has a built-in script that will return the encoded information to
its original binary format by running as a shell command. Both tools were
once crucial to sending binary information across the Internet via email.
Suppose you want to encode a 38Kb binary image called
can do it by trying the following:
$ cat mykitty.jpg | uuencode - > mykitty.ascii.uu
$ uudecode -o mykitty.jpg mykitty.ascii.uu Returns it to
$ shar mykitty.jpg > mykitty.ascii.sh
$ sh mykitty.ascii.sh Returns it to binary form
Did you notice that the ASCII-encoded files are larger? Remember, when you send a 1Mb zipped file across the Internet, you are sending a file that is significantly larger than what presently sits on your computer.
I knew a sysadmin who worked on contract with several firms. He would often
keep track of his machines by having automated reports sent to his personal
account supplied by his ISP. There was, however, a bit of a problem: although he
had plenty of space allotted to his account, he was limited to each individual
email being no larger than 5Mb. His solution was to use
Here is a typical listing of the files after the archives have been created for a contract he called companyMega:
companyMega.01 companyMega.06 companyMega.11 companyMega.16 companyMega.21 companyMega.02 companyMega.07 companyMega.12 companyMega.17 companyMega.22 companyMega.03 companyMega.08 companyMega.13 companyMega.18 companyMega.23 companyMega.04 companyMega.09 companyMega.14 companyMega.19 companyMega.24 companyMega.05 companyMega.10 companyMega.15 companyMega.20 companyMega.25
Here's a snippet of code that was run as part of a
shar -L 4000 -o companyMega companyMega.logs.tar.gz
Now loop and mail the individual archives through a script called
for u do echo attachment backup for $u | mutt -a $u -s $u email@example.com done
The script was invoked in the active directory as follows:
sh sendoff.sh `ls companyMega.*`
An alternative to
mutt is the old standby
cat $u | mail -s bakup:$u firstname.lastname@example.org
The difference between this command and the former is by using
mutt, I've sent off the backup as a MIME attachment. That is a bit
cleaner to deal with for those of the non-scripting persuasion — just manually
save the attachment into a directory of your choosing.
Reassembling the file is trivial:
unshar -e companyMega.*
Email is as important as the telephone. Security is the buzzword on the Internet these days. My next article will continue this discussion on email and demonstrate how to carry out authentication and encryption with several email clients using OpenSSL.
Robert Bernier is the PostgreSQL business intelligence analyst for SRA America, a subsidiary of Software Research America (SRA).
Return to the Linux DevCenter.
bcc: the "b" stands for "blind" not "blank"
2003-05-23 12:29:53 anonymous2 [View]
2003-05-22 23:31:31 anonymous2 [View]
How to pass through proxy servers?
2003-05-26 10:58:49 anonymous2 [View]