nodemailer是一个流行的Node.js模块,用于发送电子邮件。它支持各种邮件传输协议,包括SMTP、SMTPS、Sendmail和Amazon SES等。
使用nodemailer发送邮件到office@company.ro地址的步骤如下:
npm install nodemailer
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
host: 'smtp.example.com',
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: 'your-email@example.com',
pass: 'your-password'
}
});
请注意,上述示例中的SMTP服务器地址、端口、认证信息需要根据你的实际情况进行配置。
const mailOptions = {
from: 'your-email@example.com',
to: 'office@company.ro',
subject: 'Hello',
text: 'This is a test email from nodemailer.'
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log('Error occurred:', error);
} else {
console.log('Email sent:', info.response);
}
});
以上代码将发送一封包含"Hello"作为主题和"This is a test email from nodemailer."作为正文的邮件到office@company.ro地址。
推荐的腾讯云相关产品:腾讯企业邮件(https://cloud.tencent.com/product/exmail)
腾讯企业邮件是腾讯云提供的一款高效稳定的企业级邮件服务,支持海量邮箱账号的创建和管理,提供安全可靠的邮件收发、群组协作、日程管理等功能,适用于各类企业和组织的邮件通信需求。
希望以上信息能对你有所帮助!
没有搜到相关的文章