12

Using Windows (2008) is there an easy command line tool that I can use to send a test email from a server to test the SMTP, user authentication, ports, etc... without writing my own?

17

Your best, easiest and most globally available tool: telnet

  1. At command prompt, type: telnet mail.mailserver.com 25
  2. Type EHLO , and then press ENTER.
  3. Type AUTH LOGIN. The server responds with an encrypted prompt for your user name.

    Enter your user name encrypted in base 64. You can use one of several tools that are available to encode your user name.

    The server responds with an encrypted base 64 prompt for your password. Enter your password encrypted in base 64.

  4. Type MAIL FROM:, and then press ENTER. If the sender is not permitted to send mail, the SMTP server returns an error.

  5. Type RCPT TO:,and then press ENTER.If the recipient is not a valid recipient or the server does not accept mail for this domain, the SMTP server returns an error.

  6. Type DATA.

    If desired, type message text, press ENTER, type a period (.), and then press ENTER again.

    If mail is working properly, you should see a response similar to the following indicating that mail is queued for delivery:

    250 2.6.0 MAILID-SOMETHINGHERE@mail.somedomain.com.

Quoted in part from this MS Technet article

  • haha, I don't quote know if this is "easy" but it's certainly a fairly foolproof method. – Mark Henderson Aug 5 '09 at 4:09
  • It is easy enough... luckily I didn't need to do authentication (local server) so I didn't have to worry about the base64 encoding, although many sites are available that can help me with that if necessary. – Jason Aug 7 '09 at 1:02
13

For me, the easiest method is using Send-MailMessage in Powershell. From the Powershell console simply run:

PS C:\Users\admin> Send-MailMessage -SMTPServer smtp.domain.com -To xxxxx@gmail.com -From youremail@domain.com -Subject "This is a test email" -Body "Hi, this is a test email sent via PowerShell to test the STMP relay server"

Loads more options can be found on this link:

  • 1
    useful powershell snippet – vijay shiyani Oct 15 '15 at 0:29
4

If this is something that you have to test once in a while, or just for a small number of SMTP servers, then telnet may be the most convenient tool, as it has been pointed out. The best thing about telnet is that it's an almost universal tool, and that it allows you not only to test an SMTP server but also other services like POP, IMAP, etc.

However, if you're performing this tests regularly or on a bigger scale, i'd highly recommend using swaks. It's extremely easy to use and can also perform other tasks like sending attached files (which can be useful for testing your mail content filters).

It will also give you useful exit codes, so that you can even use it to perform automated tests.

I use it frequently on Linux, but being a Perl script, you should be able to run it on a Windows box without any problems.

  • Nine years later, I can also recommend swaks. On Mac OS, install with brew install swaks. – tuomassalo Nov 9 '18 at 12:39
1

If you don't want to manually run through the entire SMTP transaction you can use a command line tool such as blat to send emails.

0

Telnet to port 25 and issuing SMTP commands by hand is usually fine for this purpose.

0

You can try an online service that will do the work for you. You can quickly find out about common SMTP server issues

https://checkeremail.com/smtp-check

  • This is not a solution to the problem as OP asked, as it does not handle user authentication. Even if it did, sending those credentials to a random third party site is an awful idea. – Matthew FitzGerald-Chamberlain Nov 7 '18 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.