Formatting

This commit is contained in:
Kurt Hutten
2021-06-29 17:17:21 +10:00
parent 726945c2ab
commit 7417499d4b
11 changed files with 92 additions and 66 deletions

View File

@@ -1,4 +1,4 @@
import nodemailer, {SendMailOptions} from 'nodemailer'
import nodemailer, { SendMailOptions } from 'nodemailer'
interface Args {
to: SendMailOptions['to']
@@ -15,42 +15,49 @@ interface SuccessResult {
messageSize: number
response: string
envelope: {
from: string | false,
from: string | false
to: string[]
},
}
messageId: string
}
export function sendMail({to, from, subject, text}: Args): Promise<SuccessResult> {
let transporter = nodemailer.createTransport({
export function sendMail({
to,
from,
subject,
text,
}: Args): Promise<SuccessResult> {
const transporter = nodemailer.createTransport({
host: 'smtp.mailgun.org',
port: 587,
secure: false,
tls: {
ciphers:'SSLv3'
ciphers: 'SSLv3',
},
auth: {
user: 'postmaster@mail.cadhub.xyz',
pass: process.env.EMAIL_PASSWORD
}
});
pass: process.env.EMAIL_PASSWORD,
},
})
console.log({to, from, subject, text});
console.log({ to, from, subject, text })
const emailPromise = new Promise((resolve, reject) => {
transporter.sendMail({
from,
to,
subject,
text,
}, (error, info) => {
if (error) {
reject(error);
} else {
resolve(info);
transporter.sendMail(
{
from,
to,
subject,
text,
},
(error, info) => {
if (error) {
reject(error)
} else {
resolve(info)
}
}
});
)
}) as any as Promise<SuccessResult>
return emailPromise
}