add otp page, mailer.js
This commit is contained in:
1 parent
515dd5a62c
commit
9fbc958d87
6 files changed
+186
-17
No files matched your search
@@ -1,11 +1,35 @@
|
||||
import nodemailer from "nodemailer";
|
||||
|
||||
// Create a transporter using SMTP
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: "smtp.example.com",
|
||||
host: "us1.smtp.bird.com",
|
||||
port: 587,
|
||||
secure: false, // use STARTTLS (upgrade connection to TLS after connecting)
|
||||
auth: {
|
||||
user: process.env.SMTP_USER,
|
||||
pass: process.env.SMTP_PASS,
|
||||
user: "bird",
|
||||
pass: "", // TODO: use environment variables
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
await transporter.verify();
|
||||
console.log("Server is ready to take our messages");
|
||||
} catch (err) {
|
||||
console.error("Verification failed:", err);
|
||||
}
|
||||
|
||||
try {
|
||||
const info = await transporter.sendMail({
|
||||
from: '"CPC Security" <[email protected]>', // sender address
|
||||
to: "[email protected]", // list of recipients
|
||||
subject: "Hello", // subject line
|
||||
text: "Hello world?", // plain text body
|
||||
html: "<b>Hello world?</b>", // HTML body
|
||||
});
|
||||
|
||||
console.log("Message sent: %s", info.messageId);
|
||||
// Preview URL is only available when using an Ethereal test account
|
||||
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
|
||||
} catch (err) {
|
||||
console.error("Error while sending mail:", err);
|
||||
}
|
||||
Reference in new issue
Block a user