Да, это довольно просто, я использую nodemailer: npm install nodemailer --save
var mailer = require('nodemailer');
mailer.SMTP = {
host: 'host.com',
port:587,
use_authentication: true,
user: 'you@example.com',
pass: 'xxxxxx'
};
Затем прочитайте файл и отправьте электронное письмо:
fs.readFile("./attachment.txt", function (err, data) {
mailer.send_mail({
sender: 'sender@sender.com',
to: 'dest@dest.com',
subject: 'Attachment!',
body: 'mail content...',
attachments: [{'filename': 'attachment.txt', 'content': data}]
}), function(err, success) {
if (err) {
// Handle error
}
}
});