SMTP connection using telnet
July 2019
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
This site is an effort to share some of the base knowledge I have gathered through all this years working with Linux, FreeBSD, OpenBSD, Python or Zope, among others. So, take a look around and I hope you will find the contents useful.
Recent Entries
Recent Comments
Recent Trackbacks
OpenBSD (9 items)
BSD (0 items)
FreeBSD (19 items)
Linux (3 items)
Security (3 items)
Python (22 items)
Zope (13 items)
Daily (144 items)
e-shell (9 items)
Hacks (14 items)
PostgreSQL (3 items)
OSX (8 items)
Nintendo DS (0 items)
enlightenment (0 items)
Apache (3 items)
Nintendo Wii (1 items)
Django (24 items)
Music (12 items)
Plone (7 items)
Varnish (0 items)
Lugo (2 items)
Sendmail (0 items)
europython (7 items)
Cherokee (1 items)
self (1 items)
Nature (1 items)
Hiking (0 items)
uwsgi (0 items)
nginx (0 items)
cycling (10 items)
Networking (1 items)
DNS (0 items)

Syndicate this site (XML)

RSS/RDF 0.91

10 julio

SMTP connection using telnet

another reminder for my damaged brain...

Did you ever need to test a SMTP server quickly?

If the answer is yes, probably you had hear something about using telnet to send emails directly.

I've used this trick a thousand times myself, but I always forget the correct commands and the order I have to provide them to the SMTP server.

Transcription follows:

[Fenris] ~> telnet 25
Connected to
Escape character is '^]'.
220 [ ESMTP Codigo23 mail server ] - [ Will Hack Unix for food ]
ehlo localhost Hello [], pleased to meet you
250-SIZE 5242880
250 HELP
mail from:
250 2.1.0 Sender ok
rcpt to:
250 2.1.5 Recipient ok
354 Enter mail, end with "." on a line by itself
This is a sample mail sent to you via telnet!
250 2.0.0 m6AB3LDP071599 Message accepted for delivery


1- Connect to the server using telnet:

telnet 25

2- Say hello to the server:

ehlo localhost

3- Tell the server who is sending the email:

mail from:

4- Then tell it the destination address:

rcpt to:

5- Finally tell the server you are about to write the message contents:


NOTE: If you want to add a subject to your mail, just add a line like:

Subject: this is my subject

at the beginning of the body. You will need to press enter twice for it to work properly.

6- Once you are done, push enter, then add a single dot (.) and push enter again.

7- Mail sent!

(Anyone who can teach us how to do that using netcat??)

Posted by wu at 13:11 | Comments (1) | Trackbacks (0)
<< Noticias en prensa escrita | Main | Debugging your webapp, the funny way >>
Re: SMTP connection using telnet

Hi There,

Thanks for a great tutorial but i have a question for you.

The 1st step where you connect to the server, how do you identify the server whe using an internet cafe?

Please help.
Your co-operation will be appreciated.


Posted by: Sifiso at noviembre 04,2008 09:33
Re: SMTP connection using telnet

Hi Sifiso, I don't know exactly what do you meant with "how do you identify the server whe using an internet cafe?" but you can use tools like dig (if you are using a unix-like operating system like linux or bsd) or nslookup (if you are using windows) to know the FQDN or the ip address of the MX record for a given domain.

For example, if you want to know the name of the mail server for the domain, with dig you can do something like:

dig MX

Just use google and search for dig, dig MX or nslookup and you will probably find what you need.

Posted by: Wu at noviembre 04,2008 12:58
Re: SMTP connection using telnet

E-Shell is not working anymore. Any Idea?

Posted by: Falcon at febrero 25,2015 13:01
Please send trackback to:
There are no trackbacks.
Post a comment