SMTP using nodemailer in nodejs without GMail

Hitu picture Hitu · Sep 29, 2014 · Viewed 18.5k times · Source

I am using node mailer with GMail

smtpTransport = nodemailer.createTransport("SMTP", {
    service: "Gmail",
    auth: {
        user: "myemail ",
        pass: "mypass"
    }
});

which is working fine, but I want to use my own email server instead of GMail.

This:

smtpTransport = nodemailer.createTransport("SMTP", {
    service: "mymailservr link url",
    port : 25
    auth: {
        user: "myemail ",
        pass: "mypass"
    }
});

It throws this error:

connect ECONNREFUSED

Answer

jgillich picture jgillich · Sep 29, 2014

The service option is only for well-known services. To specify your own host, set host.

var smtpTransport = nodemailer.createTransport('SMTP', {
    host: 'yourserver.com',
    port: 25,
    auth: {
        user: 'username',
        pass: 'password'
    }
});