Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SMTP using nodemailer in nodejs without GMail

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

like image 923
Hitu Avatar asked Sep 29 '14 12:09

Hitu


1 Answers

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'
    }
});
like image 106
jgillich Avatar answered Oct 05 '22 23:10

jgillich