Reputation: 1994
We've developed several applications hosted in Bluemix that use SendGrid to send emails. Since last week, everyone of these applications started failing after no changes whatsoever in none of them.
It turns out that Bluemix started timing out the requests to SendGrid. We thought it was SendGrid's problem, so we replaced the service with Amazon SES, and to our dismay, we started getting exactly the same error.
Here is what the logs look like:
We put together this simple NodeJS application that gives us the error to see if someone sees what's wrong, or tries it out and lets us know whether this is actually failing on a different Bluemix account:
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);
{
"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"
}
}
applications:
- path: .
memory: 512M
instances: 1
domain: mybluemix.net
name: ibm-email-nodejs
host: ibm-email-nodejs
disk_quota: 1024M
command: node app.js
Upvotes: 0
Views: 796
Reputation: 305
The port 587 should work. Reference : http://blog.mailgun.com/25-465-587-what-port-should-i-use/
Did you try that? Please check out the code at https://github.com/sendgrid/smtpapi-nodejs/blob/master/examples/example.js
// Use nodemailer to send the email
var settings = {
host: "smtp.sendgrid.net",
port: parseInt(587, 10),
requiresAuth: true,
auth: {
user: process.env.SENDGRID_USERNAME,
pass: process.env.SENDGRID_PASSWORD
}
};
Upvotes: 1