This content originally appeared on DEV Community and was authored by MOHSIN ALI SOOMRO
Enable these
lesssecure
DisplayUnlockCaptcha
import nodemailer from "nodemailer";
async function sendEmail(to, subject, text) {
try {
const transport = nodemailer.createTransport({
port: 587,
host: "smtp.gmail.com",
auth: {
user: "<Your Email>",
pass: "<Your Password>",
},
});
const option = {
from: "<Email>",
to: to,
subject: subject,
text: text,
};
const result = await transport.sendMail(option);
console.log("function", { result });
return result;
} catch (error) {
return error;
}
}
This content originally appeared on DEV Community and was authored by MOHSIN ALI SOOMRO
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.

APA
MLA
MOHSIN ALI SOOMRO | Sciencx (2022-02-07T08:00:18+00:00) Send email with nodemailer. Retrieved from https://www.scien.cx/2022/02/07/send-email-with-nodemailer/
" » Send email with nodemailer." MOHSIN ALI SOOMRO | Sciencx - Monday February 7, 2022, https://www.scien.cx/2022/02/07/send-email-with-nodemailer/
HARVARDMOHSIN ALI SOOMRO | Sciencx Monday February 7, 2022 » Send email with nodemailer., viewed ,<https://www.scien.cx/2022/02/07/send-email-with-nodemailer/>
VANCOUVERMOHSIN ALI SOOMRO | Sciencx - » Send email with nodemailer. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/07/send-email-with-nodemailer/
CHICAGO" » Send email with nodemailer." MOHSIN ALI SOOMRO | Sciencx - Accessed . https://www.scien.cx/2022/02/07/send-email-with-nodemailer/
IEEE" » Send email with nodemailer." MOHSIN ALI SOOMRO | Sciencx [Online]. Available: https://www.scien.cx/2022/02/07/send-email-with-nodemailer/. [Accessed: ]
rf:citation » Send email with nodemailer | MOHSIN ALI SOOMRO | Sciencx | https://www.scien.cx/2022/02/07/send-email-with-nodemailer/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.