Added message to sent filder
This commit is contained in:
parent
ab6840de79
commit
1ebcb64a3b
|
@ -15,6 +15,7 @@ var fs = require('fs');
|
|||
var Imap = require('imap');
|
||||
var MP = require('mailparser-mit').MailParser;
|
||||
var nodemailer = require('nodemailer');
|
||||
var mimemessage = require('mimemessage');
|
||||
|
||||
/**
|
||||
* Global env.
|
||||
|
@ -1366,23 +1367,77 @@ if (
|
|||
});
|
||||
if (send) {
|
||||
send = false;
|
||||
transporter.sendMail(
|
||||
{
|
||||
from: options_smtp.auth.user,
|
||||
to: headers_[i].to,
|
||||
subject: 'RE: ' + headers_[i].subject,
|
||||
html: message
|
||||
},
|
||||
function(err) {
|
||||
if (err) console.error('sendMail', err);
|
||||
console.log(
|
||||
'REPLY',
|
||||
headers_[i].to,
|
||||
'RE: ' + headers_[i].subject
|
||||
);
|
||||
callback();
|
||||
var mailOptions = {
|
||||
from: options_smtp.auth.user,
|
||||
to: headers_[i].to,
|
||||
subject: 'RE: ' + headers_[i].subject,
|
||||
html: message
|
||||
};
|
||||
transporter.sendMail(mailOptions, function(err) {
|
||||
if (err) console.error('sendMail', err);
|
||||
console.log(
|
||||
'REPLY',
|
||||
headers_[i].to,
|
||||
'RE: ' + headers_[i].subject
|
||||
);
|
||||
if (!err && modules.abuse.data.smtp.host.indexOf('yandex') + 1) {
|
||||
var imap2 = new Imap(options_imap);
|
||||
imap2.once('ready', function() {
|
||||
imap2.openBox('Sent', false, function(err, box) {
|
||||
if (err) {
|
||||
console.error('openBox Sent', err);
|
||||
imap2.end();
|
||||
callback();
|
||||
}
|
||||
let msg, htmlEntity;
|
||||
msg = mimemessage.factory({
|
||||
contentType: 'multipart/alternate',
|
||||
body: []
|
||||
});
|
||||
htmlEntity = mimemessage.factory({
|
||||
contentType: 'text/html;charset=utf-8',
|
||||
body: mailOptions.html
|
||||
});
|
||||
msg.header(
|
||||
'Message-ID',
|
||||
'<' +
|
||||
Math.random()
|
||||
.toString(36)
|
||||
.substr(2, 5) +
|
||||
'>'
|
||||
);
|
||||
msg.header('From', mailOptions.from);
|
||||
msg.header('To', mailOptions.to);
|
||||
msg.header('Subject', mailOptions.subject);
|
||||
msg.header('Date', new Date());
|
||||
msg.body.push(htmlEntity);
|
||||
imap2.append(
|
||||
msg.toString(),
|
||||
{
|
||||
mailbox: 'Sent',
|
||||
flags: ['Seen'],
|
||||
date: new Date(Date.now())
|
||||
},
|
||||
function(err) {
|
||||
if (err) {
|
||||
console.error('APPEND', err);
|
||||
}
|
||||
imap2.end();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
imap2.once('error', function(err) {
|
||||
console.error('SENT FOLDER', err);
|
||||
callback();
|
||||
});
|
||||
imap2.once('end', function() {
|
||||
console.error('SENT', mailOptions.to, mailOptions.subject);
|
||||
callback();
|
||||
});
|
||||
imap2.connect();
|
||||
}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
"isbot": "2.4.2",
|
||||
"limax": "2.0.0",
|
||||
"mailparser-mit": "1.0.0",
|
||||
"mimemessage": "1.0.5",
|
||||
"maxmind": "3.1.2",
|
||||
"md5": "2.2.1",
|
||||
"memcached": "2.2.2",
|
||||
|
|
Loading…
Reference in a new issue