如何使用nodejs中的附件发送电子邮件?
问题描述:
该程序完美工作,但不会发送附件文件。任何人都可以给我正确的解决方案吗?提前致谢。如何使用nodejs中的附件发送电子邮件?
var nodemailer = require('nodemailer');
var fs=require("fs");
var smtpTransport = require('nodemailer-smtp-transport');
var transporter = nodemailer.createTransport(smtpTransport({
service: 'Gmail',
host: 'smtp.gmail.com',
port: 465,
auth: {
user: '[email protected]',
pass: 'xvbthhegebeb.'
}
}));
transporter.sendMail({
from: "[email protected]",
subject:" hello ji " ,
text: "I would like to write dialogue",
Attachments:[
{
'filename':'link.txt',
'path': 'E:/STUDIES/CORE SUBJECTS/link.txt'
}
],
to: "[email protected]"
}, function(error, info) {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
console.log("Mail sent successfully");
});
谢谢老兄这是工作非常..... –
@VigneshRavi欢迎StackOverflow上。您现在可以将其标记为正确的答案。 – dashmug