Testing SMTP from CLI

By EssingtonITS team ·

Learn how to test SMTP from the command line by connecting to a mail server, sending a test email, and troubleshooting common errors. This guide covers the essential commands and steps for successful email transmission.

To gain access to your email account, you will need the following three essentials:
  • A stable and active internet connection
  • The address of a mail server that can handle relaying, which is usually provided by your email service provider (e.g., mail.domain.ext)
  • A legitimate email address (e.g., mail@domain.ext)
Utilize the command line interface to initiate a connection from your computer to your designated mail server.
 
telnet mail.domain.ext 25
 
You should receive a response that looks something like this:
 
Trying ???.???.???.???... Connected to mail.domain.ext. Escape character is '^]'. 220 mail.domain.ext ESMTP Sendmail ?version-number?; ?date+time+gmtoffset?
 
Proceed by indicating the origin of your email:
 
HELO local.domain.name
 
The exact local domain name is not critical, though using your fully qualified domain name as recognized externally is recommended. The mail server needs to trust your input as per the standards set by RFC822-RFC1123.
 
Reply 250 mail.domain.ext Hello local.domain.name [loc.al.i.p], pleased to meet you
 
Next, enter your email address:
 
MAIL FROM: mail@domain.ext
 
Reply
 
250 2.1.0 mail@domain.ext... Sender ok
 
Now, input the recipient's email address:
 
 
Reply
 
250 2.1.0 mail@otherdomain.ext... Recipient ok
 
To start composing your email message, use the following command:
 
DATA If you wish to include a subject for your email, type Subject:-type subject here- then press enter twice (these are required to comply with RFC 882) You can now proceed to write the body of your message.
 
 This is a test email
 
To signal to the mail server that you have completed your message, enter a single period
 
 .
 
Reply
 
250 2.0.0 ???????? Message accepted for delivery.
 
To close the connection, use the following command:
 
QUIT
 
Reply
 
221 2.0.0 mail.domain.ext closing connection Connection closed by foreign host.
 
Errors
  • 501 nouser@nosuchplace.here... Sender domain must exist
  • 503 Need MAIL before RCPT - A recipient has been specified before a sender.
  • 550 mail@domain.ext... Relaying Denied - The mail server has refused to relay mail for you.

Looking to enhance your Linux infrastructure? At EssingtonITS.co.uk, we offer expert support and tailored solutions to optimise your systems. Let us help you achieve seamless integration and improved performance.

person people found this useful.

Related

Knowledge base 24 Nov 2026

SDE PC Terminal: turn a PC or laptop into a Terminal

The SDE PC image allows a 64-bit PC or laptop to function as an SDE Terminal, providing a streamlined setup for accessing SDE desktops. It's suitable for machines that can't run Windows 11 and can be run from a USB key or installed on the disk.

Knowledge base 23 Nov 2026

SDE Labs tutor guide: classes and students' copies

The article provides a comprehensive guide for tutors and Labs admins on managing SDE Labs classes, including creating classes, setting parameters, and handling student copies. It covers essential admin tasks like pausing classes, resetting student copies, and generating reports.

Knowledge base 23 Nov 2026

SDE Labs troubleshooting

This guide provides troubleshooting steps for common issues in SDE Labs, such as blueprint saving errors and console access problems. It includes causes and solutions for each problem, aimed at engineers, Labs admins, and helpdesk staff.

Expand 29 Jul 2026

How AI can support pupils with SEND

Explore how AI tools are aiding pupils with special educational needs and disabilities by simplifying text, breaking down tasks, and enhancing accessibility. Learn about the considerations schools should make before implementation.

Expand 29 Jul 2026

AI policy and practice in further education

Further education colleges need distinct AI policies due to their unique mix of vocational courses, diverse age groups, and specific funding and inspection requirements. This guidance highlights the importance of tailored AI approaches in FE settings.