2017-09-15 98 views
0

我想知道是否有人已經想出瞭如何使用GoDaddy託管的電子郵件與nodemailer。我從我的接觸形式的電子郵件提交框,它觸發了下面的腳本:使用GoDaddy設置nodemailer時出錯535

function sendEmail (to, subject, body) { 

var transporter = nodemailer.createTransport({ 
    service: 'Godaddy', 
    host: "relay-hosting.secureserver.net", 
    port: 465, 
    secureConnection: true, 
    auth: { 
    user: '[email protected]', 
    pass: 'password' 
    } 
    }); 

var mailOptions = { 
    from: '[email protected]', 
    to: to, 
    subject: subject, 
    text: body 
}; 

transporter.sendMail(mailOptions, function(error, info){ 
    if (error) { 
    console.log(error); 
    } else { 
    console.log('Email sent: ' + info.response); 
    } 
}); 
} 

我已經嘗試了一些不同的選擇,並確保我的端口都開放,但我有一個硬與認證的時間。我不斷收到這樣的錯誤:

{ Error: Invalid login: 535 Authentication Failed for [email protected] User does not have any relays assigned. 
    at SMTPConnection._formatError (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:577:19) 
    at SMTPConnection._actionAUTHComplete (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:1306:34) 
    at SMTPConnection._responseActions.push.str (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:349:26) 
    at SMTPConnection._processResponse (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:733:20) 
    at SMTPConnection._onData (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:529:14) 
    at Socket._socket.on.chunk (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:481:47) 
    at emitOne (events.js:96:13) 
    at Socket.emit (events.js:188:7) 
    at readableAddChunk (_stream_readable.js:176:18) 
    at Socket.Readable.push (_stream_readable.js:134:10) 
    at TCP.onread (net.js:547:20) 
    code: 'EAUTH', 
    response: '535 Authentication Failed for [email protected] User does not have any relays assigned.', 
    responseCode: 535, 
    command: 'AUTH PLAIN' } 

任何想法或建議將非常感激。

回答

2

看來這個錯誤與主機名有關。試試這個:

var transporter2 = nodemailer.createTransport({ 
    service: 'Godaddy', 
    host: "smtpout.secureserver.net", 
    secureConnection: true, 
    port: 465 
})