DEV Community

Cover image for How to Test SMTP Settings under 5 Minutes
Berk
Berk

Posted on • Updated on

How to Test SMTP Settings under 5 Minutes

Overview

In this tutorial, you will see how to test SMTP settings with a tool named gomtp on Linux and macOS cli.

gomtp is a open-source and free software to test SMTP settings. You can see the source code on the Github page.

Table of Contents

  1. Install the gomtp tool.
  2. Configure the SMTP settings.
  3. Test the configuration.

Install gomtp

To install the gomtp, you can simply run the command below:

sudo curl -L -o /usr/local/bin/gomtp "https://github.com/safderun/gomtp/releases/latest/download/gomtp-$(uname -s)-$(uname -m)" && \
sudo chmod +x /usr/local/bin/gomtp
Enter fullscreen mode Exit fullscreen mode

SMTP configuration.

To test SMTP settings, you first need to configure a yaml file.

  • Create a file named gomtp.yaml.
vim gomtp.yaml
Enter fullscreen mode Exit fullscreen mode

❗The file name must be gomtp.yaml by default.

  • Configure the SMTP settings for your needs.
##### Gmail Example #####
 username: 'from@gmail.com'
 password: 'appPassword'
 from: 'from@gmail.com'
 to: 'to@example.com'
 host: 'smtp.gmail.com'
 port: 587
 ssl: false
 tls: true
 auth: 'LOGIN'
 subject: 'Testing Email'
 body: |
   this is line 1
   This is line 2
Enter fullscreen mode Exit fullscreen mode

ℹ You can find some other example configurations under the repository.

Test the Configuration

Now it's time to test the configuration.

  • Be sure that you are in the same directory with the gomtp.yaml file you have just created previously.

  • Run the gomtp directly with no argument.

gomtp
Enter fullscreen mode Exit fullscreen mode
  • If the configuration is valid, you will see this output.
$ gomtp
Email sent successfully!
Enter fullscreen mode Exit fullscreen mode
  • If the configuration is invalid, you will see an error message that describe the problem.
$ gomtp
2023/12/21 11:44:33 535 5.7.8 Error: authentication failed: Invalid user or password! 1703148273-WiJ7lX77XKo0
Enter fullscreen mode Exit fullscreen mode

Top comments (0)