-
-
Save ngxson/e85bfa425c3dab0681ee7fc4dfb66e0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| // npm i smtp-client | |
| const {SMTPClient} = require('smtp-client'); | |
| let message = 'From: "Girl Hà Đông" <hi@ngxson.com>\r\n' | |
| + 'To: "Boy Hà Nội" <xaeyyctwoeoa@dropmail.me>\r\n' | |
| + 'Date: Sat, 14 Mar 2020 16:00:00 0000\r\n' | |
| + 'Subject: Đây là cái tiêu đề email\r\n' | |
| + '\r\n' | |
| + 'Xin chào boy HN. Đây là nội dung email tôi muốn gửi cho bạn.\r\n'; | |
| let s = new SMTPClient({ | |
| host: 'mx.dropmail.me', | |
| port: 25 | |
| }); | |
| let log = console.log; | |
| (async function() { | |
| log(await s.connect()); | |
| log(await s.greet({hostname: 'ngxson.com'})); // runs HELO command | |
| log(await s.mail({from: 'hi@ngxson.com'})); // runs MAIL FROM command | |
| log(await s.rcpt({to: 'xaeyyctwoeoa@dropmail.me'})); // runs RCPT TO command | |
| log(await s.data(message)); // runs DATA command and streams email source | |
| log(await s.quit()); // runs QUIT command | |
| })().catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment