2016-09-29 60 views
1

我使用express,nodemailer,& express來測試通過gmail帳戶發送電子郵件。但由於某種原因,我無法發送它。此外帳戶的電子郵件和密碼是100%正確的,仍然我得到這個錯誤。錯誤不告訴問題在哪裏。不可靠通過節點郵件發送電子郵件|無效的發件人「[email protected]>」

此外,我已經「打開」gmail設置,即降低了應用程序的設置。

我還沒有使用http://nodemailer.com/2-0-0-beta/using-oauth2/即使使用此電子郵件ID登錄到瀏覽器,我是否需要使用該功能?

我確實需要在不使用瀏覽器的情況下進行開發,但我希望看到它在以前工作。

{[Error:Invalid sender ********** @ gmail.com>「code:'EENVELOPE',command:'API'} /Users/jay/code/gmailSendEmail/app.js:43 res.json({yo:'error'}); ^

var nodemailer = require('nodemailer'); 

var express = require('express'); 
var app = express(); 
var nodeMailer = require('nodemailer'); 
var transporter = nodemailer.createTransport(); 

console.log (' coming here 1'); 



var router = express.Router(); 
app.use('/sayHello', router); 
router.post('/', handleSayHello); // handle the route at yourdomain.com/sayHello 

function handleSayHello(req, res) { 
    // Not the movie transporter! 
    var transporter = nodemailer.createTransport({ 
     service: 'Gmail', 
     auth: { 
      user: '****@gmail.com', // Your email id 
      pass: '*****' // Your password 
     } 
    }); 


var mailOptions = { 
    from: '*****@gmail.com>', // sender address 
    to: '*****@gmail.com', // list of receivers 
    subject: 'Email Example', // Subject line 
    text: 'Hello world ' //, // plaintext body 
    // html: '<b>Hello world ✔</b>' // You can choose to send an HTML body instead 
}; 


console.log (' coming here 2'); 

transporter.sendMail(mailOptions, function(error, info){ 
    console.log (' beginning emial sending '); 
    if(error){ 
     console.log('got - error here');   
     console.log(error); 
     res.json({yo: 'error'}); 
    }else{ 
     console.log ('no error emial sending ') 
     console.log('Message sent: ' + info.response); 
     res.json({yo: info.response}); 
    }; 
}); 

} 

handleSayHello(); 

回答

7

剛從

var mailOptions = { 
    from: '*****@gmail.com', // sender address 
    to: '*****@gmail.com', // list of receivers 
    subject: 'Email Example', // Subject line 
    text: 'Hello world ' //, // plaintext body 
    // html: '<b>Hello world ✔</b>' // You can choose to send an HTML body instead 
}; 
+0

什麼我也做了同樣的錯誤,在這裏結束了賠率刪除「>」! – phpdroid

相關問題