Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function appendEmail(userId, from, to, subject, html) {
- const message =
- `From: ${from}\r\n
- To: ${to}\r\n
- Subject: ${subject}\r\n
- \r\n
- ${html}\r\n
- `;
- const currentUser = _.head(await SyncQuery.find(User, { id: userId }));
- const { imapEmail, imapPassword, imapServer } = currentUser;
- const imap = new IMAP({
- user: imapEmail,
- password: imapPassword,
- host: imapServer,
- port: 993,
- tls: true,
- });
- const options = {
- mailbox: 'Sent Items',
- };
- imap.once('ready', () => {
- imap.append(message, options, (err) => {
- sails.log.error(new Error(err));
- imap.end();
- });
- });
- imap.once('error', (err) => {
- sails.log.error(new Error(err));
- });
- imap.connect();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement