Mik*_*ike 0 sendgrid nodemailer
我试图通过使用apikey的sendgrid在node.js中获得一个简单的联系表单并运行.目前还不清楚我哪里出错了.
我尝试了以下方法:1.
var options = {
auth: {
api_user: 'xjh-4XqZGH6$HLT-IEOPFG',
api_key: 'SG.xjh-4XqZGH6$HLT-IEOPFG.Wl2rB-CN00-nj3x5NiKno7MpDk8DxTtvgJeZfDGGI' // fake obviously, but I would like to show the structure as I am not sure whether this is correct
}
};
Run Code Online (Sandbox Code Playgroud)
和2.
var options = {
auth: {
api_user: 'xjh-4XqZGH6$HLT-IEOPFG',
api_key: 'Wl2rB-CN00-nj3x5NiKno7MpDk8DxTtvgJeZfDGGI' // fake obviously, but I would like to show the structure as I am not sure whether this is correct
}
};
Run Code Online (Sandbox Code Playgroud)
和3.
var options = {
auth: {
api_user: 'apikey',
api_key: 'SG.xnh-4XqZGH6$HLT-IEOPFG.Wl2rB-CN00-nj3x5NiKno7MpDk8DxTtvgJeZfDGGI' // fake obviously, but I would like to show the structure as I am not sure whether this is correct
}
};
Run Code Online (Sandbox Code Playgroud)
它会继续使用badusername/password返回.
它使用我的用户名(api_user)和密码(api_key)工作正常.
任何人都可以解释我需要做什么吗?
干杯,迈克
好的,我明白了.在这种情况下,您删除api_user并使用长键.例如
var options = {
auth: {
api_key: 'SG.xnh-4XqZGH6$HLT-IEOPFG.Wl2rB-CN00-nj3x5NiKno7MpDk8DxTtvgJeZfDGGI' // fake
}
Run Code Online (Sandbox Code Playgroud)
};
最好,迈克
小智 5
您可以同时使用 SMTP 和 API 密钥:
const mailer = nodemailer.createTransport({
host: 'smtp.sendgrid.net',
port: 465,
secure: true,
auth: {
user: 'apikey',
pass: 'SG.XXXX.XXXX',
},
});
Run Code Online (Sandbox Code Playgroud)
官方文档::https : //sendgrid.com/docs/API_Reference/SMTP_API/integrating_with_the_smtp_api.html
| 归档时间: |
|
| 查看次数: |
1484 次 |
| 最近记录: |