我尝试使用nodemailer在node js中发送邮件。但是我怀疑如果没有nodemailer使用发送邮件,可以使用另一个框架。能否举一些示例代码。
答案 0 :(得分:0)
您可以使用sendgrid发送电子邮件。我认为这更可靠。您将需要创建一个sendgrid帐户来获取API密钥。然后您可以执行以下操作:
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: 'test@example.com',
from: 'test@example.com',
subject: 'Sending with SendGrid is Fun',
text: 'and easy to do anywhere, even with Node.js',
html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);