2016-08-04 175 views
0

我們開發了幾個使用SendGrid發送電子郵件的Bluemix中託管的應用程序。自上週以來,所有這些應用程序在沒有任何更改後都開始失敗。從Bluemix發送電子郵件失敗

事實證明,Bluemix開始超時請求SendGrid。我們認爲這是SendGrid的問題,所以我們用亞馬遜SES取代了服務,令我們沮喪的是,我們開始得到完全相同的錯誤。

這裏是日誌的樣子:

enter image description here

我們整理了這篇簡單的NodeJS應用程序,讓我們的錯誤,看看是否有人看到了什麼問題,或者試圖出來,並讓我們知道是否這實際上是失敗在不同的Bluemix帳戶:

app.js

var express = require("express"), 
    app = express(); 

var port = process.env.VCAP_APP_PORT || 8080; 
var nodemailer = require("nodemailer"); 

app.use(express.static(__dirname + '/public')); 

app.get("/", function (request, response) { 
    var smtpTransport = nodemailer.createTransport("SMTP",{ 
     host: 'smtp.sendgrid.net', 
     port: 25, 
     auth: { 
      user: "user", 
      pass: "password" 
     } 
    }); 

    var mail = { 
     from: "[email protected]", 
     to: "[email protected]", 
     subject: "Send Email Using Node.js", 
     text: "Node.js send email test", 
     html: "<b>Node.js send email test</b>" 
    }; 

    smtpTransport.sendMail(mail, function(error, resp){ 
     if(error){ 
      console.log(error); 
      response.write(error); 
     } 
     else{ 
      console.log("Message sent: " + resp.message); 
      response.write("Message sent: " + resp.message); 
     } 

     smtpTransport.close(); 

     response.end(); 
    }); 

}); 

app.listen(port); 

的package.json

{ 
    "name": "ibm-email-nodejs", 
    "version": "0.0.1", 
    "description": "ibm email nodejs", 
    "main": "app.js", 
    "scripts": { 
    "start": "node app.js" 
    }, 
    "dependencies": { 
    "express": "~4.x", 
    "commander": "^2.6.0", 
    "http-post": "^0.1.1", 
    "http-proxy": "^1.8.1", 
    "nodemailer": "0.7.1" 
    }, 
    "engines": { 
    "node": "5.9.1", 
    "npm": "3.7.3" 
    } 
} 

manifest.yml

applications: 
- path: . 
    memory: 512M 
    instances: 1 
    domain: mybluemix.net 
    name: ibm-email-nodejs 
    host: ibm-email-nodejs 
    disk_quota: 1024M 
    command: node app.js 
+0

您發表您的用戶,並通過檢查出的代碼。請刪除它們。 –

+0

來自文檔:「許多託管提供商和ISP將端口25作爲默認實踐。嘗試連接到smtp.sendgrid.net時,請記住端口25,2525,587和465都可供使用。您可以通過端口25,2525和587上的未加密或TLS進行連接。您還可以通過端口465上的SSL進行連接。請記住,許多託管提供商和ISP將端口25視爲默認操作。如果是這種情況,請聯繫您的主機/ ISP,找出哪些端口已開放用於傳出smtp中繼。https://sendgrid.com/docs/Classroom/Basics/Email_Infrastructure/smtp_ports.html –

+0

@svpino我刪除了證書。 –

回答