Send mail through SMTP using Telnet

Developers in my office constantly complain that the SMTP server is down and no mails are being sent out. We come back saying that their application is buggy. Most often after hours of troubleshooting the problem will turn out to be the application itself.

Here’s a simple way to test your SMTP server over port 25 using Telnet to proof them wrong.

Telnet to the server via port 25.

1. Key in “EHLO example.com” and hit enter.

2. Key in “MAIL FROM: sender@domain.com” and hit enter.

3. Key in “RCPT TO: recipient@domain.com” and hit enter.

4. Key in “DATA” and hit enter.

5. Key in your message body and hit enter.

6. Key in ” . ” and press enter.

If you received the mail then your SMTP is working fine.

Sample output,


[root@abooboo tmp]# telnet 192.168.0.25 25
Trying 192.168.0.25...
Connected to 192.168.0.25 (192.168.0.25).
Escape character is '^]'.
220 smtp11.klk.example.com Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 ready at Thu, 3 Apr 2008 15:39:17 +0800
EHLO Vsource.com
250-smtp11.klk.example.com Hello [192.168.0.192]
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
250-TURN
250-ATRN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250 OK
MAIL FROM: danesh@example.com
250 2.1.0 danesh@example.com....Sender OK
RCPT TO: danesh_manoharan@example.com
250 2.1.5 danesh_manoharan@example.com
DATA
354 Start mail input; end with .
this is a test over SMTP
.
250 2.6.0 Queued mail for delivery
quit
221 2.0.0 smtp11.klk.example.com Service closing transmission channel
Connection closed by foreign host.
[root@abooboo tmp]#

[ RFC 821 ] Thanks Cinod79

  • cinod79

    oh yeah, an effective way to tell coders to learn some network skills and protocol programming skills. I often getby with netcat :)
    Any way heres the RFC. Always read the RFC..

    http://www.ietf.org/rfc/rfc0821.txt

  • http://rajaseelan.com Raja

    After DATA, add subject: My Subject to get a subject in your email.

    E.g.:-
    DATA
    354 Start mail input; end with .
    subject: What’s Metallica’s Famous Test Phrase?
    Testicles 1-2-3
    .
    250 2.6.0 Queued mail for delivery

  • http://wingloon.com Wing Loon

    Cool… I use this every time to troubleshoot SMTP issue. How about finding another solution for sending email using SMTP authentication? Hehehe…

  • http://www.kongtechnology.com Kitkat
  • http://thedaneshproject.com Danny
  • http://wingloon.com Wing Loon

    Cool, thanks bro, :)

  • srinivas mutyala

    Helped alot , thank bhayaa !!

    [root@abooboo tmp]# telnet 192.168.0.25 25
    Trying 192.168.0.25…
    Connected to 192.168.0.25 (192.168.0.25).
    Escape character is ‘^]’.
    220 smtp11.klk.example.com Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 ready at Thu, 3 Apr 2008 15:39:17 +0800
    EHLO Vsource.com
    250-smtp11.klk.example.com Hello [192.168.0.192]
    250-AUTH GSSAPI NTLM LOGIN
    250-AUTH=LOGIN
    250-TURN
    250-ATRN
    250-SIZE
    250-ETRN
    250-PIPELINING
    250-DSN
    250-ENHANCEDSTATUSCODES
    250-8bitmime
    250-BINARYMIME
    250-CHUNKING
    250-VRFY
    250 OK
    MAIL FROM: danesh@example.com
    250 2.1.0 danesh@example.com….Sender OK
    RCPT TO: danesh_manoharan@example.com
    250 2.1.5 danesh_manoharan@example.com
    DATA
    354 Start mail input; end with .
    this is a test over SMTP
    .
    250 2.6.0 Queued mail for delivery
    quit
    221 2.0.0 smtp11.klk.example.com Service closing transmission channel
    Connection closed by foreign host.
    [root@abooboo tmp]#

  • soldeir

    No AUTH at 250 still outlook can send email but telnet fail asking the AUTH

  • Mel

    Email addresses in RCPT TO and MAIL FROM need to be enclosed between angle brackets. Even though some SMTP servers accept without, it’s increasingly more popular to enable strict RFC 822 mode for addressing, because it prevents a good portion of virus mailers and some spam software to send mail to you.

  • LeoP

    Hi.

    I can attach files?

    Leop

    • http://thedaneshproject.com Danesh

      I don’t think it’s possible but then again I’m not 100% sure on that. It’s mainly used to test SMTP servers.

      I’ll ask around

  • pegasus40218

    Very useful reference. As a developer, I see things from a slightly different perspective. In my office, the problems we’ve had with SMTP have not been with the SMTP server going down, but someone screwing up the firewall settings essentially blocking SMTP requests coming from the servers that my applications are running on.

  • Pingback: Envoyer un email depuis une application Windows 8.1 : Utiliser StreamSocket pour créer un client Smtp - Mim's Blog - Site Home - MSDN Blogs

  • Pingback: Sending an email within a Windows 8.1 application : using StreamSocket to emulate a SmtpClient - Mim's Blog - Site Home - MSDN Blogs

© 2008-2012 The Danesh Project
Powered by Wordpress and made by Guerrilla. Hosted at ServerFreak