nodemailer 附件_如何使用Nodemailer发送带有附件的电子邮件。 Node.js
nodemailer 附件
In the previous article, "How to send emails using Nodemailer?", we discussed how to send simple emails using Nodemailer in Node.js? Here, we are going to learn further – How to send emails with attachments using Nodemailer in Node.js?
在上一篇文章“ 如何使用Nodemailer發送電子郵件? ”中,我們討論了如何在Node.js中使用Nodemailer發送簡單的電子郵件? 在這里,我們將進一步學習– 如何使用Node.js中的Nodemailer發送帶有附件的電子郵件?
Here is the code to send emails with attachments using Nodemailer,
這是使用Nodemailer發送帶有附件的電子郵件的代碼,
// load the node mailer module var nodemailer = require('nodemailer'); //configure the transportervar transporter = nodemailer.createTransport({ service: 'gmail',auth: {user: '[email?protected]',pass: 'your gmail password'} });//email optionsvar mailOptions = {from: '[email?protected]',to: '[email?protected]',subject: 'Sending Email using Node.js',text: 'sending email with attchments',// attachment. // you can use the same format and send as many attachments as possibleattachments: [ { filename: 'textfile.txt',path: 'C:/Users/GODWILL TETAH/Downloads/textfile.txt'} ] };transporter.sendMail(mailOptions, function(error, info){if (error) {console.log(error);} else {console.log('Email sent');} });To add attachment from a cloud storage system online, you can use the URL,
要在線從云存儲系統添加附件,您可以使用以下網址,
{ // use URL as an attachmentfilename: 'license.txt',path: 'https://raw.github.com/nodemailer/nodemailer/master/LICENSE' },Note: You can use the same format and send as many attachments as possible. Make sure the closing curly bracket of each attachment is separated by a comma sign (,).
注意:您可以使用相同的格式并發送盡可能多的附件。 確保每個附件的大括號用逗號(,)分隔。
Finally, start your node app and if sending is successful, the phrase ‘email sent' will be printed out on the console or terminal.
最后,啟動您的節點應用程序,如果發送成功,則將在控制臺或終端上打印出短語“已發送電子郵件”。
Check you're the email's inbox.
檢查您是否是電子郵件的收件箱。
Using Gmail as your transporter, you can also enable the less secure app access setting.
使用Gmail作為傳輸者,您還可以啟用安全性較低的應用訪問設置。
Sending email requires internet connection.
發送電子郵件需要互聯網連接。
Do not fear about your password security. It's a tested and secured module used by many since 2010.
不要擔心您的密碼安全性。 自2010年以來,它已被許多人使用并經過測試和保護。
Also, don't forget the comma sign (,) that kind of separates the text content and the attachment.
另外,請不要忘記用逗號(,)分隔文本內容和附件。
It gave me some hard time when preparing this article.
在編寫本文時,這給了我一些困難。
Thanks for coding with me! See you @ the next article. Feel free to drop a comment or question.
感謝您與我編碼! 下次見。 隨意發表評論或問題。
翻譯自: https://www.includehelp.com/node-js/how-to-send-emails-with-attachments-using-nodemailer-node-js.aspx
nodemailer 附件
總結
以上是生活随笔為你收集整理的nodemailer 附件_如何使用Nodemailer发送带有附件的电子邮件。 Node.js的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 假体取出多少钱啊?
- 下一篇: 梦之蓝6多少钱一瓶啊?