45 lines
794 B
TypeScript
45 lines
794 B
TypeScript
'use server'
|
|
|
|
import nodemailer from 'nodemailer'
|
|
|
|
const transporter = nodemailer.createTransport({
|
|
host: 'smtp.gmail.com',
|
|
port: 465,
|
|
secure: true,
|
|
auth: {
|
|
user: 'vista@ugmail.org',
|
|
pass: 'hqhowacppifsefxl'
|
|
}
|
|
})
|
|
|
|
type SendMailProps = {
|
|
email: string
|
|
subject: string
|
|
text: string
|
|
html: string
|
|
}
|
|
|
|
export async function sendMail({email, subject, text, html}: SendMailProps) {
|
|
try {
|
|
const info = await transporter.sendMail({
|
|
from: `"BeWell" <vista@ugmail.org>`,
|
|
to: email,
|
|
bcc: [
|
|
'yevhen.odynets@gmail.com',
|
|
'shopping@amok.space',
|
|
{
|
|
name: 'Actus Septem',
|
|
address: 'actus.septem@ukr.net'
|
|
}
|
|
],
|
|
subject,
|
|
text,
|
|
html
|
|
})
|
|
|
|
return {ok: true, messageId: info.messageId}
|
|
} catch (e) {
|
|
return {ok: false, message: JSON.stringify(e)}
|
|
}
|
|
}
|