Skip to content

Instantly share code, notes, and snippets.

@thomstratton
Last active May 15, 2026 14:49
Show Gist options
  • Select an option

  • Save thomstratton/3ea7620ebbf4ac3d38aeb9017b231925 to your computer and use it in GitHub Desktop.

Select an option

Save thomstratton/3ea7620ebbf4ac3d38aeb9017b231925 to your computer and use it in GitHub Desktop.
send-test-email-using-openssl.md

example send email using openssl

  • this being done on a mac with available commands.
  • this example is using mailgun and AUTH LOGIN method. may need to be adjusted for different providers.

first get hashes for your username and password

echo -n username@example.com|base64
echo -n password|base64

Note

some login methods may require combining these strings with null character /0. in these cases may need to use printf instead of echo in cases where username or password starts with a digit and follows /0.

Note

troubleshooting the generated string: printf yourBase64hash|base64 -d | od -c

starting session smtp session:

openssl s_client -connect smtp.mailgun.org:587 -starttls smtp

You should see something similar to this:

CONNECTED(00000005)
...truncated for brevity, lots of certificate / connection info may display and eventually you see
---
250 STARTTLS

issue command:

auth login

you should see a prompt similar to this: (the string is the base64 encoded prompt Username:

334 VXNlcm5hbWU6

paste in the base64 encoded username from earlier and hit enter.

next you should see a prompt similar to this (the string is the base64 encoded prompt Password:

334 UGFzc3dvcmQ6

paste in the base64 encoded password from earlier and hit enter.

you should get 235 Authentication successful

now send mail by issuing mail commands.

mail from:username@example.com
250 Sender address accepted
rcpt to:testrecipient@another.example.com
250 Recipient address accepted
data
354 Continue
subject:hello test
this is a hello test email
.
250 Great success
quit
221 See you later. Yours truly, Mailgun
closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment