Search code examples
emailsmtptelnetmailgunbulk-mail

How to send a test email over SMTP with Mailgun using telnet?


I have configured Mailgun for my domain: blog.kop.com (fake domain), I have reset my SMTP password for this domain on mailgun dashboard.

I usually use the Mailgun API, this is why I want to test the SMTP sending from command line to check that I have the correct credentials, as an example, I'll use the following password:

  • Username: postmaster@blog.kop.com (guessed by me)
  • Password: d3bec33d3bc3e333333b3e333a3e33-3a3aa3d3-333ddf3 (given by mailgun)

This is what I do:

  1. Convert the username to base64:
$ echo postmaster@blog.kop.com | base64
cG9zdG1hc3RlckBibG9nLmtvcC5jb20K
  1. Convert the password to base64:
$ echo d3bec33d3bc3e333333b3e333a3e33-3a3aa3d3-333ddf3 | base64
ZDNiZWMzM2QzYmMzZTMzMzMzM2IzZTMzM2EzZTMzLTNhM2FhM2QzLTMzM2RkZjMK
  1. Test send email over SMTP on port 587 (STARTTLS) with telnet client:
$ telnet smtp.mailgun.org 587
Trying 3.93.221.84...
Connected to smtp.mailgun.org.
Escape character is '^]'.
220 Mailgun Influx ready
ehlo blog.kop.com
250-smtp-out-n01.prod.us-east-1.postgun.com
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-SMTPUTF8
250-PIPELINING
250 STARTTLS
AUTH LOGIN
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBibG9nLmtvcC5jb20K
334 UGFzc3dvcmQ6
ZDNiZWMzM2QzYmMzZTMzMzMzM2IzZTMzM2EzZTMzLTNhM2FhM2QzLTMzM2RkZjMK
535 Authentication failed
Connection closed by foreign host.

It seems that my credentials are incorrect, this is mailgun documentation for sending mail over SMTP: https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-smtp

I also tried using there code snippet and their swaks program: https://documentation.mailgun.com/en/latest/quickstart-sending.html#send-via-smtp

I also have the wrong credentials. I copy pasted the credentials and aknowledged that they are correct.

I already got this issue using the API, the mailgun documentation was providing the wrong api address for europe region. I now believe smtp.mailgun.org is not the right server for Europe region but I can't find anything related to it.

  • What's wrong with those steps?
  • Why I am failing to send email?
  • How can I send email over SMTP with mailgun, starttls and telnet?

Solution

  • For europe, the SMTP address is smtp.eu.mailgun.org.