Amila Iddamalgoda Amila Iddamalgoda - 4 months ago 21
Node.js Question

Node.js + Nodemailer + Sending mail through ipage smtp

I need to send emails to my clients using ipage email address through my node.js app. Currently, I'm using https://nodemailer.com as the node module. Following will be my code. I'm getting a Connection timeout error as the err. Is there anything I missed? Any tips or insights on this ? Please help me out.

Code
enter image description here

Answer

Its beacuse the credentials you are passing in

var transporter = nodemailer.createTransport();

are not completed.

Here is an example of the fields you can pass.

var transporter = nodemailer.createTransport(smtpTransport ({
        auth: {
            user: config.EMAIL.EMAIL.USER,
            pass: config.EMAIL.EMAIL.PASS
        },
        host: config.EMAIL.HOST,
        secureConnection: config.EMAIL.SECURECONNECTION,
        port: config.EMAIL.PORT,
        tls: {
            rejectUnauthorized: config.EMAIL.TLS.REJECTUNAUTHORIZED
        },
    }));

Here i have stored my credentials in my config file, you can pass them directly here.