diff --git a/migrations/users/bulk-email.js b/migrations/users/bulk-email.js index 88f67e095f..fb48ce5d58 100644 --- a/migrations/users/bulk-email.js +++ b/migrations/users/bulk-email.js @@ -16,11 +16,11 @@ async function updateUser (user) { if (count % progressCount === 0) console.warn(`${count} ${user._id}`); - sendTxn( + await sendTxn( user, EMAIL_SLUG, [{ name: 'BASE_URL', content: BASE_URL }], // Add variables from template - ); + ).catch(err => console.error(err)); return User.update({ _id: user._id }, { $set: { migration: MIGRATION_NAME } }).exec(); } diff --git a/website/server/libs/email.js b/website/server/libs/email.js index 634d60ad9d..da241c571b 100644 --- a/website/server/libs/email.js +++ b/website/server/libs/email.js @@ -66,7 +66,7 @@ export function getGroupUrl (group) { } // Send a transactional email using Mandrill through the external email server -export function sendTxn (mailingInfoArray, emailType, variables, personalVariables) { +export async function sendTxn (mailingInfoArray, emailType, variables, personalVariables) { mailingInfoArray = Array.isArray(mailingInfoArray) ? mailingInfoArray : [mailingInfoArray]; // eslint-disable-line no-param-reassign, max-len variables = [ // eslint-disable-line no-param-reassign, max-len @@ -130,7 +130,7 @@ export function sendTxn (mailingInfoArray, emailType, variables, personalVariabl } if (IS_PROD && mailingInfoArray.length > 0) { - got.post(`${EMAIL_SERVER.url}/job`, { + return got.post(`${EMAIL_SERVER.url}/job`, { auth: `${EMAIL_SERVER.auth.user}:${EMAIL_SERVER.auth.password}`, json: true, body: {