2016-10-04 47 views
0

如何從表單(姓名,電子郵件,附件)收集數據並使用快遞將其提交給我的電子郵件。我沒有找到關於此主題的綜合文章。我將非常感謝您的幫助。如何使用節點和快遞將表單提交給電子郵件

+0

不,我沒有。我是前端開發人員,但對節點的使用經驗不多。 –

+0

您可以在Internet上找到一些文章(http://javascript.tutorialhorizo​​n.com/2015/07/02/send-email-node-js-express/)。我想,你的問題對於網站的範圍來說太狹窄了。 – drinchev

回答

3

我正在考慮你知道如何提交表單

要通過節點發送的任何郵件安裝流行的模塊「nodemailer」在你的項目目錄

1安裝nodemailer模塊

npm install nodemailer 

2 - 到您正在處理的控制器的表單提交服務器上的數據

var express = require('express'), 
nodemailer = require("nodemailer"); 

app = express.createServer(); 

app.use(express.bodyParser()); 

app.post('/formProcess', function (req, res) { 
    var data=req.body; 

    var smtpTransport = nodemailer.createTransport("SMTP",{ 
     service: "Gmail", 
     auth: { 
     user: "[email protected]", 
     pass: "gmailPassword" 
     }}); 

    smtpTransport.sendMail({ //email options 
    from: "Sender Name <[email protected]>", 
    to: "Receiver Name <[email protected]>", // receiver 
    subject: "Emailing with nodemailer", // subject 
    html: "here your data goes" // body (var data which we've declared) 
    }, function(error, response){ //callback 
     if(error){ 
      console.log(error); 
     }else{ 
      console.log("Message sent: " + res.message); 
     } 

    smtpTransport.close(); 
    }); }); 
相關問題