英文:
How to use custom mails with nodemailer other than gmail?
问题
我在一个微服务项目或 CRM 中工作。为了发送邮件,我正在使用 nodemailer 与 Gmail 服务,但它只适用于 Gmail 邮箱。但我需要从其他邮箱发送邮件,比如 .....@iteccounsel.com 或 ....@quadque.digital,但这不起作用。此外,我不知道如何为这些邮箱设置应用程序密码。目前我正在使用我用于登录的原始密码。我尝试设置应用程序密码,但在这些邮箱的设置中找不到任何选项。那么,我需要改变什么以使其他邮箱正常工作?
Nodemailer 代码:
let transporter = nodemailer.createTransport({
port: 465,
secure: true,
service: "gmail",
auth: {
user: ".......@quadque.digital",
pass: ".........",
},
});
我需要在我的代码中做任何更改吗?在服务中我应该使用什么代替 Gmail?
英文:
I am working in an micro service project or crm. For sending mail I am using nodemailer with service gmail which is only working with gmail emails. But I need to send mail from other emails such as .....@iteccounsel.com or ....@quadque.digital which is not working. Also I don't know how to set app passwords for these mails. Currently I am using the original password which I use to login. I tried to set app password but didn't find any settings for these mails. So what to change to make other mails work ?
Nodemailer code :
let transporter = nodemailer.createTransport({
port: 465,
secure: true,
service: "gmail",
auth: {
user: ".......@quadque.digital",
pass: ".........",
},
});
Is there anything I need to change in my code ? And what should I use instead of gmail in service ?
答案1
得分: 1
你可以从nodemailer.createTransport
中移除service
属性。
添加一个名为host
的属性,并填写你的自定义SMTP主机。
另外,如果你改变端口从465,请记得修改secure
属性。
示例:
let transporter = nodemailer.createTransport({
host: 'something.domain.com',
port: 465,
secure: true, // 如果你想要其他端口而不是465,请将其改为false
auth: {
user: 'username@domain.com', // 你的电子邮件地址
pass: 'password' // 你的密码
}
});
最后,你可以使用这个传输器来发送邮件。
希望这有所帮助。
问候。
英文:
You can remove the service
prop from your nodemailer.createTransport
.
Add a prop named host
and fill it with your custom smtp host.
Also, remember to change secure
prop in case you change the port from 465.
Example:
let transporter = nodemailer.createTransport({
host: 'something.domain.com',
port: 465,
secure: true, // Change it to false if you wanted another port than 465
auth: {
user: 'username@domain.com', // Your email address
pass: 'password' // Your password
}
});
Finally, you can use the transporter to send mail.
I hope this helps.
Regards.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论