Test SMTP Server – How to Guide

linuxsmtp

I received SMTP server information and credentials and want to test if they work.

How can I easily test a SMTP connection on Linux using the command line?

I know I can do this via telnet / openssl but this seems very complicated.

So how to check a SMTP server?

Best Answer

The tool swaks comes in handy here

On Ubuntu it's

apt install swaks

Then you can run the command and will see the SMTP dialog

$ swaks --to foo@example.com --server smtp.ionos.de:587
=== Trying smtp.ionos.de:587...
=== Connected to smtp.ionos.de.
<-  220 kundenserver.de (mreue106) Nemesis ESMTP Service ready
 -> EHLO lafto
<-  250-kundenserver.de Hello example [<IP redacted>]
<-  250-8BITMIME
<-  250-AUTH LOGIN PLAIN
<-  250-SIZE 140000000
<-  250 STARTTLS
 -> MAIL FROM:<foo@example.com>
<** 530 Authentication required
 -> QUIT
<-  221 kundenserver.de Service closing transmission channel
=== Connection closed with remote host.

As you can see here, it's needs authentication, this is why we rerun with

$ swaks --to foo@example.com --server smtp.ionos.de:587 --auth LOGIN
Username: foo
Password: bar

Check the man page for further information