+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ addContactFormJob (fromEmail: string, fromName: string, subject: string, body: string) {
+ const emailPayload: EmailPayload = {
+ template: 'contact-form',
+ to: [ CONFIG.ADMIN.EMAIL ],
+ replyTo: `"${fromName}" <${fromEmail}>`,
+ subject: `(contact form) ${subject}`,
+ locals: {
+ fromName,
+ fromEmail,
+ body,
+
+ // There are not notification preferences for the contact form
+ hideNotificationPreferences: true
+ }
+ }
+
+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ async sendMail (options: EmailPayload) {
+ if (!isEmailEnabled()) {
+ logger.info('Cannot send mail because SMTP is not configured.')
+ return
+ }
+
+ const fromDisplayName = options.from
+ ? options.from
+ : CONFIG.INSTANCE.NAME
+
+ const email = new Email({
+ send: true,
+ htmlToText: {
+ selectors: [
+ { selector: 'img', format: 'skip' },
+ { selector: 'a', options: { hideLinkHrefIfSameAsText: true } }
+ ]
+ },
+ message: {
+ from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`
+ },
+ transport: this.transporter,
+ views: {
+ root: join(root(), 'dist', 'server', 'lib', 'emails')
+ },
+ subjectPrefix: CONFIG.EMAIL.SUBJECT.PREFIX