{"id":8930,"date":"2026-08-25T10:47:15","date_gmt":"2026-08-25T05:17:15","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=8930"},"modified":"2026-08-26T10:13:41","modified_gmt":"2026-08-26T04:43:41","slug":"sending-test-emails-using-swaks-and-smtp2go-2","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/sending-test-emails-using-swaks-and-smtp2go-2\/","title":{"rendered":"Sending Test Emails Using Swaks and SMTP2GO"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In system administration and development environments, it&#8217;s often necessary to test email-sending functionality without relying on a full application or framework. <strong>Swaks<\/strong> (Swiss Army Knife for SMTP) is a powerful command-line tool that lets you manually <strong>test SMTP with Swaks<\/strong> and validate email delivery. This guide covers how to test SMTP with Swaks using the SMTP2GO service, sending a test email over TLS with login authentication.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">I. Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before running the Swaks command, make sure the following are in place:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Swaks installed<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Debian\/Ubuntu: <code>sudo apt install swaks<\/code><\/li>\n\n\n\n<li>macOS (Homebrew): <code>brew install swaks<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. An SMTP2GO account<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A registered and configured <a href=\"https:\/\/www.smtp2go.com\/\" target=\"_blank\" rel=\"noopener\">SMTP2GO<\/a> account<\/li>\n\n\n\n<li>The SMTP server address, port number, and your SMTP username and password<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Network access<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The machine running Swaks needs outbound access to external SMTP servers on <strong>port 587<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. TLS support<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Your Swaks build should include TLS support to enable secure communication<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>5. Valid email addresses<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A valid sender address (<code>--from<\/code>) and recipient address (<code>--to<\/code>)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">II. How to Test SMTP with Swaks<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s the command to test SMTP with Swaks through SMTP2GO using TLS and login authentication:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">swaks --to sam@gmail.com \\\n      --from dev@solutions.com \\\n      --server smtp2go.com \\\n      --auth LOGIN \\\n      --auth-user admin@solutions.com \\\n      --auth-password 'yourpassword' \\\n      --port 587 \\\n      --tls \\\n      --body \"This is a test message sent using swaks.\"\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What each flag does:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Flag<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td><code>--to<\/code><\/td><td>Recipient email address<\/td><\/tr><tr><td><code>--from<\/code><\/td><td>Sender email address<\/td><\/tr><tr><td><code>--server<\/code><\/td><td>SMTP server hostname (SMTP2GO in this case)<\/td><\/tr><tr><td><code>--auth LOGIN<\/code><\/td><td>Authentication method to use<\/td><\/tr><tr><td><code>--auth-user<\/code><\/td><td>SMTP account username<\/td><\/tr><tr><td><code>--auth-password<\/code><\/td><td>SMTP account password<\/td><\/tr><tr><td><code>--port<\/code><\/td><td>SMTP port (587 is the standard submission port for TLS)<\/td><\/tr><tr><td><code>--tls<\/code><\/td><td>Enables TLS encryption for the connection<\/td><\/tr><tr><td><code>--body<\/code><\/td><td>The message body to send<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If everything is configured correctly, Swaks prints the full SMTP conversation to your terminal \u2014 including the connection handshake, authentication, and delivery confirmation \u2014 making it easy to spot exactly where a failure occurs if something goes wrong.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Security note:<\/strong> The example above includes <code>--auth-password<\/code> directly on the command line for clarity, but this isn&#8217;t safe for production or shared environments \u2014 plaintext passwords in commands can end up in shell history or process listings visible to other users on the same machine. See the next step for safer alternatives.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">III. Avoid Hardcoding Credentials<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once you&#8217;re ready to test SMTP with Swaks in a production or shared environment, avoid embedding credentials directly in the command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Use an environment variable:<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">export SMTP_PASS='yourpassword'\nswaks --to sam@gmail.com \\\n      --from dev@solutions.com \\\n      --server smtp2go.com \\\n      --auth LOGIN \\\n      --auth-user admin@solutions.com \\\n      --auth-password \"$SMTP_PASS\" \\\n      --port 587 \\\n      --tls\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Or use a secrets manager:<\/strong> tools like <code>pass<\/code>, HashiCorp Vault, or your cloud provider&#8217;s secret manager can inject credentials at runtime instead of storing them in scripts or shell history.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">IV. Conclusion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Swaks provides a simple and efficient way to validate email configurations and troubleshoot SMTP-related issues. Whether you&#8217;re testing from a local machine or integrating email into a larger workflow, using Swaks to test SMTP gives you detailed, low-level control over message sending and clear visibility into the SMTP conversation. For secure and production environments, always avoid embedding credentials in plain text \u2014 use environment variables or a proper secrets manager instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For more sysadmin testing and automation guides, see our post on <a href=\"https:\/\/pheonixsolutions.com\/blog\/jenkins-user-creation-and-permission-management-guide\/\">creating a Jenkins user and managing permissions<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why use port 587 instead of 25?<\/strong> Port 587 is the standard &#8220;submission&#8221; port designed for authenticated email sending with TLS. Port 25 is typically used for server-to-server mail transfer and is often blocked by ISPs for outbound connections.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What if the connection fails or times out?<\/strong> Check that outbound port 587 isn&#8217;t blocked by a firewall, confirm your SMTP2GO credentials are correct, and verify your Swaks build includes TLS support (<code>swaks --help<\/code> will show available options).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Can Swaks test other SMTP providers besides SMTP2GO?<\/strong> Yes \u2014 you can test SMTP with Swaks against any standard SMTP server. Just swap the <code>--server<\/code>, <code>--auth-user<\/code>, and <code>--auth-password<\/code> values for your provider&#8217;s details.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In system administration and development environments, it&#8217;s often necessary to test email-sending functionality without relying on a full application [&hellip;]<\/p>\n","protected":false},"author":508,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-8930","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-2k2","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8930","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/508"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8930"}],"version-history":[{"count":2,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8930\/revisions"}],"predecessor-version":[{"id":11069,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8930\/revisions\/11069"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}