Skip to content

Commit

Permalink
emailtest update
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithriel committed Nov 8, 2023
1 parent caf02a6 commit b5edb51
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions emaildebug/emailtest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const nodemailer = require('nodemailer');
const Queue = require('bull');

Check failure on line 2 in emaildebug/emailtest.js

View workflow job for this annotation

GitHub Actions / eslint

Unable to resolve path to module 'bull'

const emailQueue = new Queue('emails');

const email = 'rpletz';
const password = 'Tree$Bi6M4k';

const transporter = nodemailer.createTransport({
host: 'webmail.bcgsc.ca',
auth: {
user: email,
pass: password,
},
tls: {
rejectUnauthorized: false,
},
pool: true,
});

const mail = {
to: `${email}@bcgsc.ca`,
subject: 'subject',
body: 'body',
};

emailQueue.process(async (job) => {
const {to, subject, body} = job.data;
const mailOptions = {
from: `${email}@bcgsc.ca`,
to,
subject,
text: body,
};
await transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error);
} else {
console.log(`Email sent: ${info.response}`);
}
});
});

emailQueue.add(mail);
emailQueue.add(mail);
emailQueue.add(mail);
emailQueue.add(mail);
emailQueue.add(mail);
emailQueue.add(mail);
emailQueue.add(mail);
emailQueue.add(mail);
emailQueue.add(mail);
emailQueue.add(mail);

0 comments on commit b5edb51

Please sign in to comment.