2015-04-03 94 views
2

Nodemailer可以通過代理髮送郵件嗎?Nodemailer通過代理

當我不用代理髮送郵件,它完美的作品,但是當我通過代理髮送郵件我有這樣的錯誤:

{ [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect' } 
{ [Error: socket hang up] code: 'ECONNRESET', sslError: undefined } 
{ [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect' } 
+0

https://github.com/andris9/Nodemailer/issues/125 – 2015-04-03 09:37:07

回答

0

我發現了一個解決方案,我用mailgun通過代理

發送郵件
'use strict'; 
var express = require('express'); 
var router = express.Router(); 
var mongojs = require('mongojs'); 
var api_key = 'key-xxxxxxxxxxxxxxxxxxxxxxxxxxx'; 
var domain = 'xxxxxxxxxxxxxxxxxx.mailgun.org'; 
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain}); 

var nodemailer = require('nodemailer'); 
var data = { 
    from: 'Excited User <[email protected]>', 
    to: '[email protected]', 
    subject: 'Hello', 
    text: 'Testing some Mailgun awesomness!' 
}; 
... 
router.get('/api/postEmail', function (req, res) { 
    mailgun.messages().send(data, function (error, body) { 
     console.log(body); 
    }); 
... 
+0

Nodemailer應該能夠通過代理髮送。您將需要在NPM中設置代理設置。例如:'npm config set https-proxy http://proxy.company.com:8080'另外請確保您的計算機上的代理設置是正確的。這是一個關於Nodemailer實用教程的鏈接 - https://kounsel.me/category/coding-for-mbas/8tWJ4/coding-for-mbas-create-a-quick-dirty-mail-merge-utility-10-分鐘 – bitanath 2017-05-16 07:05:50