Send Email
One script reply has been approved by the moderators Verified

Send an email using smtp

Created by admin 1346 days ago Picked 280 times
Submitted by hugo989 Bun
Verified 8 days ago
1
import nodemailer from "nodemailer";
2

3
export async function main(
4
  smtp_res: RT.Smtp,
5
  to_email: string,
6
  from_email: string,
7
  subject: string,
8
  content: string,
9
) {
10
  const transporter = nodemailer.createTransport({
11
    host: smtp_res.host,
12
    port: smtp_res.port,
13
    secure: smtp_res.port === 465,
14
    auth: {
15
      user: smtp_res.user,
16
      pass: smtp_res.password,
17
    },
18
  });
19

20
  await transporter.sendMail({
21
    from: from_email,
22
    to: to_email,
23
    subject: subject,
24
    text: content,
25
  });
26

27
  return `Email sent from ${from_email} to ${to_email}`;
28
}
Other submissions