How to check if smtp is working from commandline (Linux)

balanv picture balanv · Aug 16, 2012 · Viewed 405.9k times · Source

I have a SMTP-server, for the purpose of this question lets call it: smtp.mydomain.com.

How do i check if the SMTP-server is in working? Can I send emails manually from Linux commandline?

Answer

balanv picture balanv · Aug 16, 2012

Syntax for establishing a raw network connection using telnet is this:

telnet {domain_name} {port_number}

So telnet to your smtp server like

telnet smtp.mydomain.com 25

And copy and paste the below

helo client.mydomain.com
mail from:<[email protected]>
rcpt to:<[email protected]>
data
From: [email protected]
Subject: test mail from command line

this is test number 1
sent from linux box
.
quit

Note : Do not forgot the "." at the end which represents the end of the message. The "quit" line exits ends the session.