APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

TCP/IP and NFS FAQ


Some material is very old and may be incorrect today

© December 2003 (various)

How do I test a smtp connection?

When your GUI mail client doesn't work, you need to know whether the problem is at the server or the client. You could download a different client (Thunderbird, if you are using Outlook or Apple Mail) but why spend that time when you can test from the command line?

Note that some ISP's won't allow you to make port 25 connections to anything but their mail servers. This is to keep viruses from sending mail. If you need to test some other server, you may not be able to without using a system that does not impose this restriction.

The lines preceded by numbers are typical responses. The actual response may be different.


 
 $ telnet mail.somewhere.com 25
 Trying 192.168.75.194...
 Connected to smtp.somewhere.com.
 Escape character is '^]'.
 220 smtp.somewhere.net ESMTP Sendmail 8.9.3+Sun/8.9.1; Thu,
 
    12 Oct 2000 04:39:40 -0700 (PDT)
 helo aplawrence.com
 250 smtp.somewhere.com
 mail from: [email protected]
 250 [email protected] Sender ok
 rcpt to: [email protected]
 550 [email protected] Relaying denied
 rcpt to: [email protected]
 250 [email protected] Recipient ok
 data
 354 Enter mail, end with . on a line by itself
 test
 look ma no headers!
 .
 250 HA00945 Message accepted for delivery
 quit
 221 smtp.somewhere.com closing connection
 

You might also need to do a

helo mymachine.mymachine.com
 

first, and addresses may need to be in angle brackets: <[email protected]>

Remember: some ISP'S block your outgoing packets, only allowing port 25 to their SMTP server. You won't be able to test any other server if this is true.

If your server accepts secure smtp (it should), you can use openssl instead of telnet:

openssl s_client -connect mail.yourserver.com:465 -crlf
 

(If you don't use the "-crlf" you may have trouble using "." to end a DATA input)

I also have found Clean Code Email very helpful for command line testing.

If you have sendmail. you can use it from the command line with -v to see what really happens. See Debugging sendmail problems

See Microsoft's Connectivity Tester also.


If you found something useful today, please consider a small donation.



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> (SCO Unix) How do I test a smtp mail connection?

4 comments


Inexpensive and informative Apple related e-books:

Take Control of OS X Server

iOS 8: A Take Control Crash Course

Take Control of Preview

Take Control of Pages

Take Control of Apple Mail, Third Edition




Related Articles






Mon Jan 5 10:32:26 2009: 5085   aravind


The post is so usefull thanks a lot.



Wed Sep 1 17:01:50 2010: 8948   alain

gravatar


Howdy,

Iíve always used telnet for SMTP testing. Finally, got sick of copy/pasting and decided to write a quick script. But scripting telnet is a pain. Netcat to the rescue! Here's the script: (link)

Cheers,
Alain



Wed Sep 1 17:38:31 2010: 8949   TonyLawrence

gravatar


Thanks, Alain!

I'm annoyed that Verizon won't let me do this from my network anymore. I now have to ssh to my webhost to do this kind of testing.



Wed Sep 1 20:55:53 2010: 8952   alain

gravatar


Yep, ISPs blocking port 25 is all too common. That's why I configure my smtp boxes to listen on 465 and 587 as well, which typically aren't blocked.

------------------------


Printer Friendly Version


Related Articles

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us


Printer Friendly Version





Let us try to teach generosity and altruism, because we are born selfish. (Richard Dawkins)




Linux posts

Troubleshooting posts


This post tagged:

FAQ

Mail

Networking



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode