7 months ago
I'm encountering an issue with sending emails from Ghost CMS hosted on Railway. Despite having correct SMTP settings with Mailgun, I consistently receive the following error in the logs:
550 5.7.1 Relaying denied
Background:
I've verified my SMTP settings with Mailgun by testing them directly using curl for both ports 587 (TLS) and 465 (SSL), and both tests were successful.
Here are the environment variables I have set in Railway for Ghost CMS:
mail__auth__user="postmaster@domain.com"
mail__from="noreply@domain.com"
mail__options__host="smtp.mailgun.org"
mail__options__port="587"
mail__options__secure="false"
mail__options__service="Mailgun"
mail__transport="SMTP"
mail__auth__pass="API_KEY_PLACEHOLDER"
curl Test Script:
I used the following curl test script to confirm that Mailgun is processing emails correctly:
#!/bin/bash
# Create a temporary file to hold the email content
EMAIL_CONTENT=$(mktemp)
# Write the email content to the temporary file
echo -e "Subject: Test Mail\n\nThis is a test email using the 587 port." > "$EMAIL_CONTENT"
# Use curl to send the email using port 587 (TLS)
curl -v --url 'smtp://smtp.mailgun.org:587' \
--user 'postmaster@domain.com:API_KEY_PLACEHOLDER' \
--mail-from 'noreply@domain.com' \
--mail-rcpt 'name@gmail.com' \
--upload-file "$EMAIL_CONTENT"
# Clean up the temporary file
rm -f "$EMAIL_CONTENT"
Can you help determine why Ghost CMS, with the same SMTP settings, fails with the relaying denied error while the curl test works fine? Is there any specific configuration or network restriction on Railway that might be causing this issue?
0 Replies
Railway logs:
[2024-09-18 01:11:41] ERROR Failed to send email. Reason: Can't send mail - all recipients were rejected: 550 5.7.1 Relaying denied.
Failed to send email. Reason: Can't send mail - all recipients were rejected: 550 5.7.1 Relaying denied.
"Please see https://ghost.org/docs/config/#mail for instructions on configuring email."
Error ID:
f6c22600-755a-11ef-bf40-fd6be1b2245d
Error Code:
EENVELOPE
----------------------------------------
Error: Can't send mail - all recipients were rejected: 550 5.7.1 Relaying denied
at createMailError (/var/lib/ghost/versions/5.94.1/core/server/services/mail/GhostMailer.js:105:12)
at SMTPConnection._formatError (/var/lib/ghost/versions/5.94.1/node_modules/nodemailer/lib/smtp-connection/index.js:807:19)
at SMTPConnection._actionRCPT (/var/lib/ghost/versions/5.94.1/node_modules/nodemailer/lib/smtp-connection/index.js:1676:28)
at SMTPConnection. (/var/lib/ghost/versions/5.94.1/node_modules/nodemailer/lib/smtp-connection/index.js:1629:30)
at SMTPConnection._processResponse (/var/lib/ghost/versions/5.94.1/node_modules/nodemailer/lib/smtp-connection/index.js:991:20)
at SMTPConnection._onData (/var/lib/ghost/versions/5.94.1/node_modules/nodemailer/lib/smtp-connection/index.js:772:14)
at SMTPConnection._onSocketData (/var/lib/ghost/versions/5.94.1/node_modules/nodemailer/lib/smtp-connection/index.js:195:44)
at TLSSocket.emit (node:events:517:28)
at TLSSocket.emit (node:domain:489:12)
at addChunk (node:internal/streams/readable:368:12)
at readableAddChunk (node:internal/streams/readable:341:9)
at Readable.push (node:internal/streams/readable:278:10)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
[2024-09-18 01:11:41] INFO "POST /members/api/send-magic-link/" 400 175ms
Mounting volume on: /var/lib/containers/railwayapp/bind-mounts/551dd4d4-0c31-4385-b427-176355bb2303/vol_th6rw2uiwqddjtbq
7 months ago
Railway does not block any outgoing traffic, nor do we have a way to do that in the first place.
7 months ago
Please see for instructions on configuring email.
Thanks @Brody
I did review those settings and also tried to it on another install using these settings and a docker-compose.yml file.
https://catchtheblock.com/how-to-setup-mailgun-in-ghost-self-hosted-docker-compose/
After this and looking at all of the other Railway Discord threads very baffling that I can get the newsletter to send out but can't get the transactional email to work.
7 months ago
I'm really sorry but we arent able to offer support for 3'rd party software
Understood. I think it might be the template - this one worked and I used the same Ghost/Railway variables
https://railway.app/template/9VGb60
It's Ghost CMS/Sqlite - mileage may vary
7 months ago
Sorry we can't do more for you here
There was another post and in it was a discussion about the Railway/Ghost templates - Error on Ghost install. I think the solution is in there - comments, tagging so that the issues can be raised about the templates.
https://discord.com/channels/713503345364697088/1195553732612587632