Ghost平台SMTP邮件配置异常:魔法链接发送失败求助
Ghost SMTP发件人配置异常排查与解决
问题现象
在Digital Ocean Droplet通过官方市场安装的Ghost中,配置SMTP后,邮件发件人始终被设为noreply@atharv.vadehra.me(Ghost默认值),而非配置的noreply@vadehra.me,且SMTP服务返回错误:
553 5.7.1 noreply@atharv.vadehra.me: Sender address rejected: not owned by user atharv@vadehra.me
当前配置(config.production.json)
"mail": { "from" : "noreply@vadehra.me", "transport": "SMTP", "options": { "host": "mail.privateemail.com", "port": 465, "secure": true, "from": "atharv@vadehra.me", "auth": { "user": "atharv@vadehra.me", "pass": "**************" } } },
错误日志片段
{"name":"Log","hostname":"ghostonubuntu2204-s-1vcpu-1gb-blr1-01","pid":211762,"level":50,"version":"5.47.1","err":{"id":"440e9970-fadc-11ed-9f77-ad3b785d7a29","domain":"https://atharv.vadehra.me","code":"EENVELOPE","name":"EmailError","statusCode":500,"level":"normal","message":"Failed to send email. Reason: Can't send mail - all recipients were rejected: 553 5.7.1 <noreply@atharv.vadehra.me>: Sender address rejected: not owned by user atharv@vadehra.me.","help":"\"Please see https://ghost.org/docs/config/#mail for instructions on configuring email.\"","stack":"Error: Can't send mail - all recipients were rejected: 553 5.7.1 <noreply@atharv.vadehra.me>: Sender address rejected: not owned by user atharv@vadehra.me\n at createMailError (/var/www/ghost/versions/5.47.1/core/server/services/mail/GhostMailer.js:68:12)\n at SMTPConnection._formatError (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:790:19)\n at SMTPConnection._actionRCPT (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:1632:28)\n at SMTPConnection.<anonymous> (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:1585:30)\n at SMTPConnection._processResponse (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:953:20)\n at SMTPConnection._onData (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:755:14)\n at TLSSocket.SMTPConnection._onSocketData (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:193:44)\n at TLSSocket.emit (node:events:513:28)\n at addChunk (node:internal/streams/readable:315:12)\n at readableAddChunk (node:internal/streams/readable:289:9)\n at TLSSocket.Readable.push (node:internal/streams/readable:228:10)\n at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)","hideStack":false},"msg":"Failed to send email. Reason: Can't send mail - all recipients were rejected: 553 5.7.1 <noreply@atharv.vadehra.me>: Sender address rejected: not owned by user atharv@vadehra.me.","time":"2023-05-25T09:12:25.995Z","v":0}
排查信息
查看GhostMailer.js代码片段,逻辑上应优先读取配置的mail.from字段,否则 fallback 到默认值:
function getFromAddress(requestedFromAddress) { const configAddress = config.get('mail') && config.get('mail').from; const address = requestedFromAddress || configAddress; // If we don't have a from address at all if (!address) { // Default to noreply@[blog.url] return getFromAddress(`noreply@${getDomain()}`); } // If we do have a from address, and it's just an email if (validator.isEmail(address, {require_tld: false})) { const defaultSiteTitle = settingsCache.get('title') ? settingsCache.get('title').replace(/"/g, '\\"') : tpl(messages.title, {domain: getDomain()}); return `"${defaultSiteTitle}" <${address}>`; } return address; }
已尝试调整from字段位置、重启Ghost,问题未解决。
解决方案
清理重复的
from配置
移除options节点下的from字段,避免与全局mail.from冲突。修改后的配置:"mail": { "from" : "noreply@vadehra.me", "transport": "SMTP", "options": { "host": "mail.privateemail.com", "port": 465, "secure": true, "auth": { "user": "atharv@vadehra.me", "pass": "**************" } } },验证别名配置
在Namecheap Private Email后台,确认noreply@vadehra.me已添加为atharv@vadehra.me的邮件别名,且完成验证步骤。确保配置文件正确加载
- 确认修改的是Ghost生产环境配置文件:
/var/www/ghost/config.production.json - 使用官方命令重启Ghost:
cd /var/www/ghost ghost restart
避免直接用
systemctl重启(市场安装的Ghost通常通过ghost-cli管理)。- 确认修改的是Ghost生产环境配置文件:
检查博客域名设置
在Ghost后台的「设置」-「通用」中,确认「博客地址」是否为https://vadehra.me(而非子域名atharv.vadehra.me),避免代码中getDomain()返回子域名导致默认发件人错误。
内容的提问来源于stack exchange,提问作者Atharv Vadehra
相关产品推荐
相关产品推荐

