Formatting
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user