diff --git a/website/api/controllers/admin/view-email-template-preview.js b/website/api/controllers/admin/view-email-template-preview.js index 6898cb3370..4e13a0cd32 100644 --- a/website/api/controllers/admin/view-email-template-preview.js +++ b/website/api/controllers/admin/view-email-template-preview.js @@ -155,6 +155,14 @@ module.exports = { notes: 'Fake organization 2 is looking for a managed cloud MDM solution with a name that ends with "eet"', }; break; + case 'email-contact-form': + fakeData = { + firstName: 'Jane', + lastName: 'Williamson', + emailAddress: 'jane@example.com', + message: 'Hi, this is a contact form message!', + }; + break; default: layout = 'layout-email-newsletter'; fakeData = { diff --git a/website/api/controllers/deliver-contact-form-message.js b/website/api/controllers/deliver-contact-form-message.js index 0ccb3c0bc5..28cca1438b 100644 --- a/website/api/controllers/deliver-contact-form-message.js +++ b/website/api/controllers/deliver-contact-form-message.js @@ -66,9 +66,26 @@ module.exports = { throw 'invalidEmailDomain'; } - await sails.helpers.http.post(sails.config.custom.slackWebhookUrlForContactForm, { - text: `New contact form message: (Remember: we have to email back; can't just reply to this thread.) cc @sales `+ - `Name: ${firstName + ' ' + lastName}, Email: ${emailAddress}, Message: ${message ? message : 'No message.'}` + // await sails.helpers.http.post(sails.config.custom.slackWebhookUrlForContactForm, { + // text: `New contact form message: (Remember: we have to email back; can't just reply to this thread.) cc @sales `+ + // `Name: ${firstName + ' ' + lastName}, Email: ${emailAddress}, Message: ${message ? message : 'No message.'}` + // }); + + await sails.helpers.sendTemplateEmail.with({ + to: sails.config.custom.fromEmailAddress, + replyTo: { + name: firstName + ' '+ lastName, + email: emailAddress, + }, + subject: 'New contact form message', + layout: false, + template: 'email-contact-form', + templateData: { + emailAddress, + firstName, + lastName, + message, + }, }); sails.helpers.salesforce.updateOrCreateContactAndAccount.with({ diff --git a/website/api/helpers/send-template-email.js b/website/api/helpers/send-template-email.js index 4679719318..ba5bac75b7 100644 --- a/website/api/helpers/send-template-email.js +++ b/website/api/helpers/send-template-email.js @@ -55,6 +55,18 @@ module.exports = { example: 'Nola Thacker', }, + replyTo: { + description: 'The reply to email address.', + example: { + email: 'anne.m.martin@example.com', + name: 'Anne M. Martin' + }, + type: { + name: 'string', + email: 'string', + } + }, + subject: { description: 'The subject of the email.', example: 'Hello there.', @@ -122,7 +134,7 @@ module.exports = { }, - fn: async function({template, templateData, to, toName, subject, from, fromName, layout, ensureAck, bcc, attachments}) { + fn: async function({template, templateData, to, toName, subject, from, fromName, layout, replyTo, ensureAck, bcc, attachments}) { var path = require('path'); var url = require('url'); @@ -247,6 +259,7 @@ module.exports = { subject: subjectLinePrefix+subject, from: from, fromName: fromName, + replyTo: replyTo, attachments }; diff --git a/website/package.json b/website/package.json index a07935e6c1..f478e37458 100644 --- a/website/package.json +++ b/website/package.json @@ -13,7 +13,7 @@ "moment": "2.29.4", "sails": "^1.5.11", "sails-hook-apianalytics": "^2.0.6", - "sails-hook-organics": "^2.2.2", + "sails-hook-organics": "^2.2.3", "sails-hook-orm": "^4.0.3", "sails-hook-sockets": "^3.0.0", "sails-postgresql": "^5.0.1" diff --git a/website/views/emails/email-contact-form.ejs b/website/views/emails/email-contact-form.ejs new file mode 100644 index 0000000000..0e8f8bf8ee --- /dev/null +++ b/website/views/emails/email-contact-form.ejs @@ -0,0 +1,15 @@ +<% /* Note: This is NOT injected into an email layout` */ %> +
+
+
+ Logo +
+
+

Message:

+
<%= message %>
+

Submitter information:

+

Name: <%= firstName %> <%= lastName %>

+

Email address: <%= emailAddress %>

+
+
+