chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
37
packages/server/lib/plugins/email/mailgun/mailgun.js
Normal file
37
packages/server/lib/plugins/email/mailgun/mailgun.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
const Mailgun = require('mailgun-js')
|
||||
|
||||
const NAME = 'Mailgun'
|
||||
|
||||
function sendMessage ({apiKey, domain, fromEmail, toEmail}, rec) {
|
||||
const mailgun = Mailgun({apiKey, domain})
|
||||
const to = rec.email.toEmail ?? toEmail
|
||||
|
||||
const emailData = {
|
||||
from: `Lamassu Server ${fromEmail}`,
|
||||
to,
|
||||
subject: rec.email.subject,
|
||||
text: rec.email.body
|
||||
}
|
||||
|
||||
return mailgun.messages().send(emailData)
|
||||
}
|
||||
|
||||
function sendCustomerMessage ({apiKey, domain, fromEmail}, rec) {
|
||||
const mailgun = Mailgun({apiKey, domain})
|
||||
const to = rec.email.toEmail
|
||||
|
||||
const emailData = {
|
||||
from: fromEmail,
|
||||
to,
|
||||
subject: rec.email.subject,
|
||||
text: rec.email.body
|
||||
}
|
||||
|
||||
return mailgun.messages().send(emailData)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
NAME,
|
||||
sendMessage,
|
||||
sendCustomerMessage
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue