Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: self signed certificate - SMTP SSL #504

Closed
anonprophet opened this issue Oct 25, 2015 · 3 comments
Closed

Error: self signed certificate - SMTP SSL #504

anonprophet opened this issue Oct 25, 2015 · 3 comments

Comments

@anonprophet
Copy link

hi, i got error when try to send email using SMTP

root@sg01:/home/node# node stats.js
SMTP Configured
Sending Mail
Error occurred
self signed certificate

this my test script

var mailer = require('nodemailer');

var transporter = mailer.createTransport({
    host: '128.199.226.xxx',
    port: 465,
    secure: true,

    auth: {
        user: 'noreply@xxx.xx',
        pass: 'xxx'
    }
});

console.log('SMTP Configured');

// Message object
var message = {

    // sender info
    from: 'KabarGames <noreply@xxx.xx>',

    // Comma separated list of recipients
    to: "tes" <xxx@outlook.com>',

    // Subject of the message
    subject: 'Nodemailer is unicode friendly ✔', //

    // plaintext body
    text: 'Hello to myself!',

    // HTML body
    html: '<p><b>Hello</b> to myself <img src="cid:note@example.com"/></p>' +
        '<p>Here\'s a nyan cat for you as an embedded attachment:<br/><img src="cid:nyan@example.com"/></p>',

    // Apple Watch specific HTML body
    watchHtml: '<b>Hello</b> to myself',

};

console.log('Sending Mail');
transporter.sendMail(message, function(error, info) {
    if (error) {
        console.log('Error occurred');
        console.log(error.message);
        return;
    }
    console.log('Message sent successfully!');
    console.log('Server responded with "%s"', info.response);
});
@nickdbush
Copy link

Try adding this:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

It tells Node to accept self signed certificates.

@andris9 andris9 closed this as completed Nov 9, 2015
@andris9
Copy link
Member

andris9 commented Jan 13, 2016

You can use this as well:

nodemailer.createTransport({
    host:'...',
    ...,
    tls:{
        rejectUnauthorized: false
    }
});

@fresheneesz
Copy link
Contributor

Deleted my comment cause i figured that out. Thanks for the quick response tho! I think the docs could use a bit of improvement, which I'll continue to do as I puzzle out how to make email work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants