Hitu Hitu - 5 months ago 65
Node.js Question

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

Answer

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'
    }
});
Comments