javascript - 使用 nodemailer 代表某人发送电子邮件
问题描述
我正在尝试代表我的用户发送一封电子邮件,nodemailer
但我的所有电子邮件都被拒绝了。
我的传输器适用于我从自己的域发送的正常用例:
const transporter = nodemailer.createTransport({
host: 'emailhost.com',
port: 465,
secure: true,
auth: {...},
dkim: {
domainName: <domainname>,
keySelector: <keyselector>,
privateKey: <privatekey>,
},
});
transporter.sendMail({
subject: "Shop subject",
from: `kyle@mydomain.com`,
to: <customerEmail>,
replyTo: <shopEmail>,
html: "<div>my user message</div>",
})
但是当我尝试代表我的用户发送时它不起作用:
transporter.sendMail({
subject: "Shop subject",
from: `shop@exampleshop.com`,
to: <customerEmail>,
// sender: `kyle@mydomain.com` <-- Also tried adding this field,
replyTo: `shop@exampleshop.com`,
html: "<div>my user message</div>",
})
>> "Can't send mail - all recipients were rejected: 553 <shop@exampleshop.com>: Sender address rejected: not owned by user kyle@mydomain.com"
我想如果我在其上设置 DKIM DNS 记录和 SPF 记录,exampleshop.com
则意味着我可以代表域发送电子邮件,但仍然没有运气。
Type: TXT Record
Host: @
Value: v=spf1 include:spf.emailhost.com ~all
// Also tried adding this record in place of the one above
Type: TXT Record
Host: @
Value: v=spf1 include:spf.mydomain.com ~all
Type: TXT Record
Host: default._domainkey
Value: v=DKIM1;k=rsa;p=<DKIM DNS record from namecheap>
自从我更新 DNS 记录以来也已经一个多小时了,我不确定我在这里做错了什么。
解决方案
推荐阅读
- javascript - 如何在按钮单击时切换元素并在外部单击时关闭?
- android - 如何为我的 android 应用程序添加代码混淆
- python - For循环使用python从硒中的excel表中读取数据
- java - 将从服务器读取的图像保存为位图到 Android 内部存储
- git - 如何让 git 从分支而不是标签中拉出?
- c++ - 当我在嵌入式设备中运行 C++ 代码时出现分段错误
- python - Python 的 lambda 列表只取最后一个值
- html - 如何在 Vuejs 中为选项卡使用路由器视图?
- ios - 如何使用 Swift iOS 向 ST17H26 发送自定义蓝牙命令?
- java - 解析后如何获取多个数组元素并将其传递给数据类