Node. js sends an email

Source: Internet
Author: User
Tags smtp auth

Occasionally, I need to send an email. I used to use Python for my work. Now I want to use my own mail. Everything is concise. As in the past, I entered npm search xxx in the command line, but this xxx is mail, and everything is concise. Then I saw nodemailer in the long search results, the introduction is "Easy to use module to send e-mails, supports unicode and SSL/TLS ". After installation, try it out to meet your needs.

It is also used in readme. An example is as follows:

Var nodemailer = require ("nodemailer"); var transport = nodemailer. createTransport ("SMTP", {host: "smtp.126.com", secureConnection: true, // use SSL port: 465, // port for secure SMTP auth: {user: "1234567@126.com ", pass: "xxxxxxx"}); transport. sendMail ({from: "1234567@126.com", to: "13JQQQQKKAA@126.com", subject: "theme? ", GenerateTextFromHTML: true, html:" Ah, hahaha "}, function (error, response) {if (error) {console. log (error);} else {console. log ("Message sent:" + response. message);} transport. close ();});

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.