[英]Sending mail with nodemailer to office@company.ro address
let transporter = nodemailer.createTransport({
service: '?',
auth: {
user: 'office@company.ro',
pass: 'passHere'
}
});
This is the code I'm using.这是我正在使用的代码。
Earlier, I was sending the emails to a Gmail address, so "service" was "gmail" and it was working perfectly.早些时候,我将电子邮件发送到 Gmail 地址,因此“服务”是“gmail”,并且运行良好。
For an address like "office@company.ro" what should I pass as "service"?对于像“office@company.ro”这样的地址,我应该将什么作为“服务”传递?
You can use SMTP API, you should use host(hostname or IP address to connect) instead of service like this:您可以使用 SMTP API,您应该使用主机(主机名或 IP 地址连接)而不是这样的服务:
nodemailer.createTransport({
host: "smtp.example.com", //<= add smtp server here
port: 587, //add port
secure: false, // upgrade later with STARTTLS
debug: true,
auth: {
user: "username",
pass: "password"
}
});
If you add logger: true to the transporter will log all the server SMTP activity out in the console.如果将 logger: true 添加到传输器,将在控制台中记录所有服务器 SMTP 活动。
So to just add to the first answer, which I totally agree with:因此,只需添加第一个答案,我完全同意:
nodemailer.createTransport({
host: "smtp.example.com", //<= add smtp server here
port: 587, //add port
secure: false, // upgrade later with STARTTLS
debug: true, // show debug output
logger: true // log information in console **NEW**
auth: {
user: "username",
pass: "password"
}
});
Mailtrap wrote a little article about it that explains both debug and logger a little more: https://blog.mailtrap.io/sending-emails-with-nodemailer/ Mailtrap 写了一篇关于它的小文章,更多地解释了调试和记录器: https://blog.mailtrap.io/sending-emails-with-nodemailer/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.