2

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?
Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204

2 Answers2

1

When you echo a string you include a newline, but the newline should not be included in the credentials you pass in to SMTP AUTH. Try

printf '%s' 'postmaster@blog.kop.com' | base64

and similarly for the password.

Using bare Telnet sounds like a pretty brittle approach; you really want to use a proper SMTP client to talk to the SMTP server.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • I tested to generate the username and password with your command and it gives me the `535 Authentication failed`. I use `telnet` because the [`commento` smtp client](https://docs.commento.io/configuration/backend/#configuration-file) cannot login using those credentials as well, the bare telnet sounds like a right approach to test the credentials without installing another client. I am still stuck. (I have also tried with thunderbird to add the smtp server but I can't choose it when sending a mail and setting it as the default still use a different smtp server) – Dimitri Kopriwa Oct 29 '20 at 10:50
  • There are simple command-line SMTP clients you can try; I would just create a Python script based on the examples in the `smtplib` documentation. – tripleee Oct 29 '20 at 10:53
  • Maybe also do `EHLO` before logging in. – tripleee Oct 29 '20 at 10:55
  • I already tried the SMTP client provided by mailgun here: https://documentation.mailgun.com/en/latest/quickstart-sending.html#send-via-smtp , it is not the SMTP client nor telnet the issue, I always use telnet to test SMTP over STARTTLS. Perhaps we should look in the right direction, what's wrong with the credentials? – Dimitri Kopriwa Oct 29 '20 at 11:08
  • Just posted the answer. – Dimitri Kopriwa Oct 29 '20 at 11:27
0

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

Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204