|
@@ -21,6 +21,12 @@ export type EmailProvider = 'smtp' | 'resend' | 'postmark' | 'mailgun' | 'sendgr
|
|
|
export interface SendMailOptions {
|
|
export interface SendMailOptions {
|
|
|
from: string
|
|
from: string
|
|
|
to: string
|
|
to: string
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Where a reply should go when it is not the sender. A support request goes
|
|
|
|
|
+ * out from the platform address, so without this the administrator's reply
|
|
|
|
|
+ * button addresses the platform itself rather than the person asking.
|
|
|
|
|
+ */
|
|
|
|
|
+ replyTo?: string
|
|
|
subject: string
|
|
subject: string
|
|
|
html: string
|
|
html: string
|
|
|
attachments?: {
|
|
attachments?: {
|
|
@@ -195,6 +201,7 @@ async function sendViaSmtpWithSettings(
|
|
|
await transporter.sendMail({
|
|
await transporter.sendMail({
|
|
|
from: options.from,
|
|
from: options.from,
|
|
|
to: options.to,
|
|
to: options.to,
|
|
|
|
|
+ replyTo: options.replyTo,
|
|
|
subject: options.subject,
|
|
subject: options.subject,
|
|
|
html: options.html,
|
|
html: options.html,
|
|
|
attachments: options.attachments?.map((a) => ({
|
|
attachments: options.attachments?.map((a) => ({
|
|
@@ -247,6 +254,7 @@ async function sendViaResendWithSettings(
|
|
|
await resend.emails.send({
|
|
await resend.emails.send({
|
|
|
from: options.from,
|
|
from: options.from,
|
|
|
to: options.to,
|
|
to: options.to,
|
|
|
|
|
+ replyTo: options.replyTo,
|
|
|
subject: options.subject,
|
|
subject: options.subject,
|
|
|
html: options.html,
|
|
html: options.html,
|
|
|
attachments: options.attachments?.map((a) => ({
|
|
attachments: options.attachments?.map((a) => ({
|
|
@@ -279,6 +287,7 @@ async function sendViaPostmarkWithSettings(
|
|
|
await client.sendEmail({
|
|
await client.sendEmail({
|
|
|
From: options.from,
|
|
From: options.from,
|
|
|
To: options.to,
|
|
To: options.to,
|
|
|
|
|
+ ReplyTo: options.replyTo,
|
|
|
Subject: options.subject,
|
|
Subject: options.subject,
|
|
|
HtmlBody: options.html,
|
|
HtmlBody: options.html,
|
|
|
Attachments: options.attachments.map((a) => ({
|
|
Attachments: options.attachments.map((a) => ({
|
|
@@ -292,6 +301,7 @@ async function sendViaPostmarkWithSettings(
|
|
|
await client.sendEmail({
|
|
await client.sendEmail({
|
|
|
From: options.from,
|
|
From: options.from,
|
|
|
To: options.to,
|
|
To: options.to,
|
|
|
|
|
+ ReplyTo: options.replyTo,
|
|
|
Subject: options.subject,
|
|
Subject: options.subject,
|
|
|
HtmlBody: options.html,
|
|
HtmlBody: options.html,
|
|
|
})
|
|
})
|
|
@@ -328,6 +338,7 @@ async function sendViaMailgunWithSettings(
|
|
|
await mg.messages.create(domain, {
|
|
await mg.messages.create(domain, {
|
|
|
from: options.from,
|
|
from: options.from,
|
|
|
to: [options.to],
|
|
to: [options.to],
|
|
|
|
|
+ ...(options.replyTo && { 'h:Reply-To': options.replyTo }),
|
|
|
subject: options.subject,
|
|
subject: options.subject,
|
|
|
html: options.html,
|
|
html: options.html,
|
|
|
...(options.attachments?.length && {
|
|
...(options.attachments?.length && {
|
|
@@ -370,6 +381,7 @@ async function sendViaSendGridWithSettings(
|
|
|
const msg: MailDataRequired = {
|
|
const msg: MailDataRequired = {
|
|
|
from: options.from,
|
|
from: options.from,
|
|
|
to: options.to,
|
|
to: options.to,
|
|
|
|
|
+ replyTo: options.replyTo,
|
|
|
subject: options.subject,
|
|
subject: options.subject,
|
|
|
html: options.html,
|
|
html: options.html,
|
|
|
}
|
|
}
|
|
@@ -410,6 +422,7 @@ async function sendViaSesWithSettings(
|
|
|
const info = await transporter.sendMail({
|
|
const info = await transporter.sendMail({
|
|
|
from: options.from,
|
|
from: options.from,
|
|
|
to: options.to,
|
|
to: options.to,
|
|
|
|
|
+ replyTo: options.replyTo,
|
|
|
subject: options.subject,
|
|
subject: options.subject,
|
|
|
html: options.html,
|
|
html: options.html,
|
|
|
attachments: options.attachments?.map((a) => ({
|
|
attachments: options.attachments?.map((a) => ({
|