/
xxx.js
35 lines (28 loc) · 1.16 KB
/
xxx.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// const transporter = require('../services/smtp-transport');
const { readMailStream } = require('../helpers/mail');
exports.register = function () {
this.loginfo('Initializing !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! plugin');
// this.register_hook('queue', 'queue');
this.register_hook('mail', 'mail');
};
exports.hook_data = function (next /*, connection */) {
next();
};
exports.mail = function (next, connection /*, params */) {
connection.transaction.uuid;
connection.transaction.mail_from;
connection.transaction.rcpt_to;
connection.transaction.message_stream;
// connection.transaction.notes;
connection.relaying = true;
connection.transaction.parse_body = true;
readMailStream(connection.transaction.message_stream).then((mail) => {
this.loginfo('!!!!! TEXT: ' + mail.text);
this.loginfo('!!!!! HTML: ' + mail.html);
this.loginfo('!!!!! Date: ' + mail.date);
this.loginfo('!!!!! Subject: ' + mail.subject);
// todo эти данные надо обработать core/text
// и прислать в ответ обратное письмо что письмо получено и обработано
});
next();
};