R
Railway2mo ago
pearcy

Email Configuration Fails with "550 5.7.1 Relaying Denied"

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="[email protected]"
mail__from="[email protected]"
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"
mail__auth__user="[email protected]"
mail__from="[email protected]"
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 '[email protected]:API_KEY_PLACEHOLDER' \
--mail-from '[email protected]' \
--mail-rcpt '[email protected]' \
--upload-file "$EMAIL_CONTENT"

# Clean up the temporary file
rm -f "$EMAIL_CONTENT"
#!/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 '[email protected]:API_KEY_PLACEHOLDER' \
--mail-from '[email protected]' \
--mail-rcpt '[email protected]' \
--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?
8 Replies
Percy
Percy2mo ago
Project ID: 71b92ac0-afb1-4da1-af80-1cc0780f0330
pearcy
pearcy2mo ago
71b92ac0-afb1-4da1-af80-1cc0780f0330 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.<anonymous> (/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
[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.<anonymous> (/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
Brody
Brody2mo ago
Railway does not block any outgoing traffic, nor do we have a way to do that in the first place. Please see https://ghost.org/docs/config/#mail for instructions on configuring email.
pearcy
pearcy2mo ago
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.
Catch The Block
✉️ How to Setup Mailgun in Ghost (self hosted, docker-compose)
This short blog post aims at helping those who are struggling (like me ) to setup properly Ghost and emails (using Mailgun).
Brody
Brody2mo ago
I'm really sorry but we arent able to offer support for 3'rd party software
pearcy
pearcy2mo ago
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
Brody
Brody2mo ago
Sorry we can't do more for you here
pearcy
pearcy2mo ago
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
https://discord.com/channels/713503345364697088/1195553732612587632
Want results from more Discord servers?
Add your server