Requesting Help Troubleshooting Mailgun

I have Bitnami distro of Ghost version 5.37.0 running on Amazon Lightsail and I’m having a difficult time getting Mailgun to work.

  1. I’ve requested that ports 25, 465, and 587 be opened by Amazon.
  2. I’ve configured my config.production.json:
  "mail": {
    "from": "reTHINK HOA BLOG <noreply@mg.rethinkhoa.com>",    
    "transport": "SMTP",
    "options": {
       "service": "Mailgun",
       "host": "smtp.mailgun.org",
       "port": 587,
       "secure": false,
       "auth": {
         "user": "postmaster@mg.rethinkhoa.com",
         "pass": "96f8b6..."
       }
    }
  },
  1. When I invite a Staff, I’m getting error message:
    Error sending email! Error sending email: Failed to send email. Reason: Invalid login: 535 5.7.139 Authentication unsuccessful, the user credentials were incorrect. [MW4PR04CA0084.namprd04.prod.outlook.com 2023-03-20T15:10:09.763Z 08DB2840C71EDC7D]. Please check your email settings and resend the invitation.

  1. When I try to Sign up or Sign in as a member, I get error message:
    Oops! There was an error sending the email, please try later

Any help troubleshooting would greatly be appreciated!

Rei

There is an authentication error. Double check the password—it’s something like 24 chars.-8 chars.-8 chars.

Additionally, if you’re in Europe, make sure to use smtp.eu.mailgun.org.

If you’re still having problems, diagnose with Swaks.

https://documentation.mailgun.com/en/latest/quickstart-sending.html#send-via-api

1 Like

Thanks for suggesting swaks, @mjw .

So it seems I’m able to successfully send using swaks…but I’m still not able to send from ghost. I’ve restarted the servers just in case, but I’m still getting an invalid login/authentication unsuccessful error. Should I use port 25 instead of 587

$ ./swaks --auth         --server smtp.mailgun.org         --au postmaster@mg.rethinkhoa.com         --ap <same password as the one in the config.production.json>         --to rei...@gmail.com         --h-Subject: "Hello"         --body 'Testing some Mailgun awesomness!'
=== Trying smtp.mailgun.org:25...
=== Connected to smtp.mailgun.org.
<-  220 Mailgun Influx ready
 -> EHLO ip-...
<-  250-a4e698e106a8
<-  250-AUTH PLAIN LOGIN
<-  250-SIZE 52428800
<-  250-8BITMIME
<-  250-SMTPUTF8
<-  250-PIPELINING
<-  250 STARTTLS
 -> AUTH LOGIN
<-  334 VXNlcm5hbWU6
 -> cG9zdG1hc3RlckBtZy5yZXRoaW5raG9hLmNvbQ==
<-  334 UGFzc3dvcmQ6
 -> Y2Y1YjA5ZjU5YjgwZjQ4MDkzZTg5MTNhZTk4YTJmZjAtMzAzNDQ0NzItZWMwYzY5ZmQ=
<-  235 Authentication successful
 -> MAIL FROM:<bitnami@ip...>
<-  250 Sender address accepted
 -> RCPT TO:<rei...@gmail.com>
<-  250 Recipient address accepted
 -> DATA
<-  354 Continue
 -> Date: Mon, 20 Mar 2023 17:56:32 +0000
 -> To: rei...@gmail.com
 -> From: bitnami@ip...
 -> Subject: Hello
 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
 ->
 -> Testing some Mailgun awesomness!
 ->
 -> .
<-  250 Great success
 -> QUIT
<-  221 See you later. Yours truly, Mailgun
=== Connection closed with remote host.

Add the following after "secure": false,:

 "requireTLS": true,
1 Like

Yup, I saw that suggestion about adding “requireTLS” from your previous post (Unable to set up Mailgun).

I’ve run my config through the linter (https://jsonlint.com/) just in case I’ve overlooked some kind of formatting error.

I’ve tried different ports (25, 587, 465), quoted and unquoted.

	},
	"mail": {
		"from": "reTHINK HOA BLOG <noreply@rethinkhoa.com>",
		"transport": "SMTP",
		"options": {
			"service": "Mailgun",
			"host": "smtp.mailgun.org",
			"port": 587,
			"secure": false,
			"requireTLS": true,
			"auth": {
				"user": "postmaster@mg.mailgun.org",
				"pass": "<password>"
			}
		}
	},

I’m a little bit confused why outlook is mentioned in the error message. My account I’m using with mailgun is an outlook email. I’ve set up DNS entries in Amazon Route 53 and the Mailgun confirms the configuration with the green check. :woman_shrugging:t2:

Error sending email! Error sending email: Failed to send email. Reason: Invalid login: 535 5.7.139 Authentication unsuccessful, the user credentials were incorrect. [MW4PR02CA0023.namprd02.prod.outlook.com 2023-03-20T18:40:54.621Z 08DB27FEA98F708E]. Please check your email settings and resend the invitation.

This is incorrect; it should be your domain.

1 Like

Ooooh! I was so excited…but that was one of the remnants of trying out different things. I tried to see if I could get it to work with the sandbox email and forgot to change it back.

But it’s back to postmaster@mg.rethinkhoa.com.

Ugh…I’m so frustrated. I feel like I tried every combination except the correct one!

I’ve also made sure that SMTP is enabled from my email address, but I don’t know why this would matter since I’m using mailgun/aws.

Looking at your DNS, everything looks good, albeit you don’t have an SPF record for the bare domain. The authentication error from outlook.com makes no sense if you’re using MX records for mg.rethinkhoa.com.

Please share config,production.json in its entirety, obfuscating any passwords etc., and make no changes to the file until I come back to you.

1 Like

Thank you for your help, @mjw.

I think I need to take a 2 hour break since I’m running up against the account lock now and I’m running out of email addresses to test with.

Attached is the screenshot with the config. Hah! I promise to not make changes until you respond.

config.production.json

Ghost newsletter entries

Route 53 DNS entries

Mailgun domain settings

Well, I’m struggling to see anything wrong with your setup, especially since Swaks works for you. Did you restart Ghost (ghost restart) after making config changes?

2 Likes

@mjw Martin, I spent 2 full days troubleshooting and once you told me that you didn’t see anything wrong, I figured I’d rebuild!

:tada::tada::tada: And at last! I have I have it working!!! :tada::tada::tada:

Thanks for being patient with me. Now I can go to sleep…until I encounter the next problem. :grin:

3 Likes

Hey there. I have run into the same problem seemingly. I’ve read all posts containing the error messages I’m receiving and none of them have provided any solution.

I just edited this post to give a lot of details. For anyone that comes here after this edit:

Ensure that you have the correct SMTP address in your config.production.json.

I had changed it to smtp.mailgun.com and that failed my authentication attempts for good reason. The address I’ve setup in Mailgun is smtp.eu.mailgun.com. Notice that eu.-addition? That’s the solution for me.

1 Like