Introduction

In system administration and development environments, it’s often necessary to test email sending functionality without relying on full applications or frameworks. Swaks (Swiss Army Knife for SMTP) is a powerful command-line tool that allows users to manually test SMTP servers and email delivery. This document outlines how to use Swaks to send an email through the SMTP2GO service using TLS encryption and login authentication.


Prerequisites

Before using the Swaks command, ensure the following prerequisites are met:

  1. Swaks Installed
    • On Debian/Ubuntu: sudo apt install swaks
    • On macOS with Homebrew: brew install swaks
  2. SMTP Account with SMTP2GO
    • You must have a registered and configured SMTP2GO account.
    • Obtain the SMTP server address, port number, and your SMTP username and password.
  3. Network Access
    • Ensure the machine can access external SMTP servers on port 587.
  4. TLS Support
    • Swaks should be built with TLS support to enable secure communication.
  5. Valid Email Addresses
    • Use valid sender (--from) and recipient (--to) email addresses.

Command Example

swaks --to sam@gmail.com \
      --from dev@solutions.com \
      --server smtp2go.com \
      --auth LOGIN \
      --auth-user admin@solutions.com \
      --auth-password 'wd1ZY4' \
      --port 587 \
      --tls \
      --body "This is a test message sent using swaks."

Conclusion

Swaks provides a simple and efficient way to validate email configurations and troubleshoot SMTP-related issues. Whether you’re testing from a local machine or integrating email into a larger workflow, Swaks allows detailed control over message sending. For secure and production environments, always avoid embedding credentials in plain text and consider using environment variables or secret management tools instead.

Leave a Reply