Meteor email error for gmail server

My server.js file contains the following code segments which should configure a gmail address and send an email.

Meteor.startup(() => {
  // code to run on server at startup
    process.env.MAIL_URL = 'smtps://email_address@gmail.com:password_without_special_keys@smtp.gmail.com:465';
    
    Email.send({
        from: "from_adddress@gmail.com",
        to: "to_address@gmail.com",
        subject: "Meteor Can Send Emails via Gmail",
        text: "Its pretty easy to send emails via gmail."
    })



});

Shouldn’t my meteor app send an email when i run the app with the command

meteor

??
But it is providing the following errors. What’s wrong?

W20170718-15:36:37.701(6)? (STDERR) /home/forhadmethun/.meteor/packages/meteor-tool/.1.5.1.dvn6c8++os.linux.x86_32+web.browser+web.cordova/mt-os.linux.x86_32/dev_bundle/server-lib/node_modules/fibers/future.js:313
W20170718-15:36:37.766(6)? (STDERR)                                             throw(ex);
W20170718-15:36:37.767(6)? (STDERR)                                             ^
W20170718-15:36:37.769(6)? (STDERR) 
W20170718-15:36:37.769(6)? (STDERR) Error: Connection timeout
W20170718-15:36:37.770(6)? (STDERR)     at Object.Future.wait (/home/forhadmethun/.meteor/packages/meteor-tool/.1.5.1.dvn6c8++os.linux.x86_32+web.browser+web.cordova/mt-os.linux.x86_32/dev_bundle/server-lib/node_modules/fibers/future.js:449:15)
W20170718-15:36:37.771(6)? (STDERR)     at Mail._syncSendMail (packages/meteor.js:213:24)
W20170718-15:36:37.772(6)? (STDERR)     at smtpSend (packages/email.js:116:13)
W20170718-15:36:37.773(6)? (STDERR)     at Object.Email.send (packages/email.js:174:5)
W20170718-15:36:37.774(6)? (STDERR)     at server/main.js:28:11
W20170718-15:36:37.775(6)? (STDERR)     at Function.time (/home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/profile.js:309:28)
W20170718-15:36:37.776(6)? (STDERR)     at /home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/boot.js:347:13
W20170718-15:36:37.777(6)? (STDERR)     at /home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/boot.js:388:5
W20170718-15:36:37.779(6)? (STDERR)     at Function.run (/home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/profile.js:510:12)
W20170718-15:36:37.780(6)? (STDERR)     at /home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/boot.js:386:11
W20170718-15:36:37.781(6)? (STDERR)     - - - - -
W20170718-15:36:37.782(6)? (STDERR)     at SMTPConnection._formatError (/home/forhadmethun/.meteor/packages/email/.1.2.3.3ikb16++os+web.browser+web.cordova/npm/node_modules/node4mailer/lib/smtp-connection/index.js:558:19)
W20170718-15:36:37.784(6)? (STDERR)     at SMTPConnection._onError (/home/forhadmethun/.meteor/packages/email/.1.2.3.3ikb16++os+web.browser+web.cordova/npm/node_modules/node4mailer/lib/smtp-connection/index.js:531:20)
W20170718-15:36:37.785(6)? (STDERR)     at [object Object].<anonymous> (/home/forhadmethun/.meteor/packages/email/.1.2.3.3ikb16++os+web.browser+web.cordova/npm/node_modules/node4mailer/lib/smtp-connection/index.js:249:18)
W20170718-15:36:37.787(6)? (STDERR)     at Timer.listOnTimeout (timers.js:92:15)

I’m in the same boat as you.

Apparently for some running email@1.2.0 fixes it for some people. But I haven’t had this happen.

I can run from my localhost and it sends emails, but my production app fairs to send.

This may be port related problem. But not sure. When i was in office then those code works fine. But when i was in home there the problem happened. As the Internet service provider is different so there might be some problem. I can be sure tomorrow when i will go to office.

Check the link below,

Ahhh! You know what, I bet my Google Cloud Compute firewall is closed on that port. So an outgoing transmission on port XXX just isn’t getting out.

Explains why localhost works and production doesn’t.

Let’s see…

Looks like Google Cloud Compute has permanently closed email ports. I’ll have to use a Meteor package for sendgrid via API’s, or find an email service that doesn’t use those ports.

I had to send mail over port 2525 as google cloud compute has for sure block other ports.

had issues with sendgrid, tried mailgun with success.