Taaut
Taaut

Reputation: 457

Nodemailer Sendgrid on Compute Engine

i trying to send emails from my compute engine instance but nothing happen(no error message). When i send mails from my local pc i get the emails.

var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');

var options = {};
var transporter = nodemailer.createTransport(smtpTransport({
    service: 'SendGrid',
    auth: {
        user: 'username',
        pass: 'password'
    }
}));
module.exports = {
    sendmailto : sendmailto
}

function sendmailto(emailfrom,emailto, message){

    var mailOptions = {
        from: emailfrom, // sender address
        to: emailto, // list of receivers
        subject: 'Monitoring', // Subject line
        text: message, // plaintext body
        html: '<b>Monitoring</b>' +
        '<p> '+message+'<p>' // html body
    };

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

    });
};

Upvotes: 1

Views: 282

Answers (1)

Taaut
Taaut

Reputation: 457

I found the reason be myself:) Service "Sendgrid use as standard port the 25 but is does not work with compute engine so i need to add the port 2525.

var transporter = nodemailer.createTransport(smtpTransport({
    service: 'SendGrid',
    port: '2525',
    auth: {
        user: 'username',
        pass: 'password'
    }
}));

Upvotes: 2

Related Questions