[Solved] How to send email in local environment?

Hello
I want to send email using local environment. I set my gmail smtp but always getting “ETIMEDOUT” error .

It works for me using mailgun.com services (free under 10k mails / month)
just export MAIL_URL=smtp://postmaster%40...
before your start your local meteor app

I have used mailgun smtp but getting “ETIMEDOUT” error in Email.send method.

Antivirus? Firewall?

No, it’s not Antivirus or Firewall issue. I am getting error in Email.send method.

This error means that your application couldn’t connect to email server.

Any solution about this?

https://github.com/nodemailer/nodemailer/issues/749 similar issue. Did you check rules in your antivirus/firewall? Could you please share your EMAIL_URL string without username/password

The problem is that this works perfectly fine for the rest of us. So you will need to give more information about what you are doing in order to help debug your issue

import { Meteor } from ‘meteor/meteor’

import { Email } from ‘meteor/email’

Meteor.startup(() => {

process.env.MAIL_URL = here is smtp

})

// Server: Define a method that the client can call.

Meteor.methods({

sendEmail(to, from, subject, text) {

    // Make sure that all arguments are strings.

    check([to, from, subject, text], [String]);

    // Let other method calls from the same client start running, without

    // waiting for the email sending to complete.

    this.unblock();

    Email.send({ to, from, subject, text });

}

});
Here is my code.

I have used mailtrap smtp. working fine.
Thanks

Unfortunately it looks like mailgun’s 10k emails for free package no longer exists :frowning_face:. Now it’s 5k free for 3 months, then $0.80 / 1000 emails after that.

Fortunately those of us who signed up before the price changes still get the 10k per month!

I signed up years ago yet I’ve received an email about the cancellation of the free packed a few days ago. Do I have to do something to still get the 10k per month for free?

Sadly today I received the email from mailgun notifying me of the change from the legacy “Concept” plan to the new “Flex plan”, effective 1st March. Still, only $0.80 per 1000 emails isn’t bad, and maybe it will prevent the spammers from getting the shared IPs blacklisted all the time.

Pointing to a remote hosted mail service isn’t really a local environment. If you need to be able to test emails in a local environment with no third party connection you can try something like this package for setting up a smtp server on your localhost and viewing emails its sent https://www.npmjs.com/package/fake-smtp-server

Or your home or office Internet Service Provider will probably provide an SMTP server you can connect to.

true but that still doesn’t really solve a true local environment, you’re relying on an external connection again. ideally a local env should work even if you’ve disconnected from the internet, so you can still develop even if you’re somewhere without internet access and without relying on a third party’s uptime