Edits history of script submission #22290 for ' Send Email (smtp)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import nodemailer from "nodemailer";
    
    export async function main(
      smtp_res: RT.Smtp,
      to_email: string,
      from_email: string,
      subject: string,
      content: string,
    ) {
      const transporter = nodemailer.createTransport({
        host: smtp_res.host,
        port: smtp_res.port,
        secure: smtp_res.port === 465,
        auth: {
          user: smtp_res.user,
          pass: smtp_res.password,
        },
      });
    
      await transporter.sendMail({
        from: from_email,
        to: to_email,
        subject: subject,
        text: content,
      });
    
      return `Email sent from ${from_email} to ${to_email}`;
    }

    Submitted by hugo989 55 days ago