Using Your E-Mail Account With Telnet
These directions are being left up mainly for historical interest, but they might sometimes still be useful
Note: You should not do this over an unencrypted telnet connection anymore. Either SSH into the server and do it there, or use a secure alternative like OpenSSL s_client.
Make sure you know your mail server, email address, and username to access your mail.
Usually POP3 and SMTP mail servers are the same, but sometimes they vary. Nowadays,
your username is most likely your full e-mail address.
Using telnet through a command line should work in Linux, FreeBSD, Macintosh, UNIX, and versions of Windows that are Windows XP or later.
Historically, you could use your shell or command line run a command like:
- telnet your.mailserver.com 110 — to check mail
- telnet your.mailserver.com 25 — to send mail
These days this is discouraged because the transmission is not secure. Instead you can do the same thing using OpenSSL.
- openssl s_client -connect mail.megapipe.net:pop3s (for POP3) or openssl s_client -connect mail.megapipe.net:imaps (for IMAP) — to check mail
- telnet your.mailserver.com 25 — to send mail
Checking your E-Mail Using Telnet or OpenSSL s_client
When the POP3 server greeting appears, type (you will not be able to see what
you are typing.):
- If your user [your username] (if your e-mail addres is email@example.com,
you would type "user mackbarb")
- POP3 informs you that the user receives mail here.
- Enter the user's password by typing: pass [password] (if
your password is rover, type pass rover)
- The following message appears: +OK Mailbox locked and ready which
indicates that POP3 is set up correctly, and is ready to deliver mail.
To determine the status of your mailbox, type: stat
- The stat command will return as message formatted as follows: +OK
3 34056. The number 3 tells you the number of messages in the mailbox.
The 34056 tells you the total number of bytes. To find out the size
of each message, type: "list"
- The LIST command returns a two-column table. The first column is the
message number, and the second column is the total size of the message
including all the header and addressing information. This is a good
command to use when you want to find and delete a troublesome message.
To read the headers of the individual messages, type: "top 1 0"
- You will see the header of message 1. If you want to see the first
few lines, type in the number of lines you want to see instead of the
0. To retrieve the message number 1, type: "retr 1"
- The RETR command displays the first message. Use the same command
to display subsequent messages To delete a message, type: "dele
[number of message to delete]" (to delete message 4, type "dele
- To end your POP3 session, type: quit and close telnet.
Sending E-Mail with Telnet
Once again, testing with telnet is only advised from a local system running a mail daemon.
A simple local test
You can connect with a command like telnet my.mail.server 25 to test local sending. Instead of port 25, it might also be worthwhile to try the email submission port 587 – though this may involve some additional steps.
When you connect, you will get a greeting from the Sendmail server. It will look something like this:
220 netgate.anent.com ESTP Metainfo Sendmail 2.5 Build 2630 (Berkeley 220.127.116.11)/8 and the date and time.
Once you have this message, do the following:
Type: helo and your email account name.
You will get the message: 250 netgate.anent.com Hello (your computer
name; your ip address). Pleased to meet you.
- Type "mail from: firstname.lastname@example.org" and
hit enter. You will get the message: Sender ok
- Type "RCPT to: email@example.com" and hit enter.
You will get the message: 250 recipient@recipient domain.com...Recipient
- Type "Data" and hit enter. You will get a message saying
354 Enter mail, ending with "." on a line by itself
- Type in your message using the format:
SUBJECT: Your subject
Your message to the recipient
Type in a dot (.) on a line by itself:
You will get the message:
250 LAAO4O80 message accepted for delivery You have now completed information
for your dial-up account.
A remote example, using openssl s_client
Many sending email servers use a feature called starttls for communication. You will begin by running one of two commands
- openssl s_client -connect mail.megapipe.net:465 – if you mail server is using a traditional TLS connection
- openssl s_client -connect mail.megapipe.net:587 -starttls smtp – if your mail server is using startls for email submission, which is not at all unusual)
To do this, you will also need to work out your username and password in base64.