balderdashy / sails-hook-email

Sails email hook
67 stars 34 forks source link

Invalid login #26

Open sakujo opened 8 years ago

sakujo commented 8 years ago

I installed sails-hook-email per npm and it is in my node_modules folder. I have set my email data in node_modules/sails-hook-email/node_modules/index.js like so:

defaults: { configKey: { service: 'Hotmail', auth: { user: 'xxxxxxxx@hotmail.de', pass: 'xxxxxxxxxxxx' }, templateDir: path.resolve(sails.config.appPath, 'views/emailTemplates'), from: 'noreply@test.com', testMode: false } }, but i do keep getting this error:

error: Sending 500 ("Server Error") response: Error: Invalid login: 535 5.0.0 Authentication Failed at SMTPConnection._formatError (/home/balcok/node_modules/smtp-connection/src/smtp-connection.js:384:15) at SMTPConnection._actionAUTHComplete (/home/balcok/node_modules/smtp-connection/src/smtp-connection.js:878:30) at SMTPConnection. (/home/balcok/node_modules/smtp-connection/src/smtp-connection.js:239:22) at SMTPConnection._processResponse (/home/balcok/node_modules/smtp-connection/src/smtp-connection.js:516:16) at SMTPConnection._onData (/home/balcok/node_modules/smtp-connection/src/smtp-connection.js:353:10) at emitOne (events.js:78:13) at TLSSocket.emit (events.js:170:7) at readableAddChunk (_stream_readable.js:147:16) at TLSSocket.Readable.push (_stream_readable.js:111:10) at TLSWrap.onread (net.js:524:20) { [Error: Invalid login: 535 5.0.0 Authentication Failed] code: 'EAUTH', response: '535 5.0.0 Authentication Failed', responseCode: 535 }

I'm sure that my login data is correct, because i'm able to login into my hotmail account with them.

duongNA commented 8 years ago

Hi sakujo, we should not change the 3rd pary code, i mean the index.js inside node_modules. You should create a file email.js inside folder config of your sails project. In email.js, export the configuration info like that module.exports.email = {. See readme for more details.

If you still meet the issue, you can post it here, maybe i can help

duongNA commented 8 years ago

Sample configuration for gmail

/**
* Configuration for email service
*/
module.exports.email = {
  transporter: {
    host: 'smtp.gmail.com',
    port: 465,
    secure: true, // use SSL
    auth: {
        user: 'sample@gmail.com',
        pass: 'xxx'
    }
  },

  from: 'sample@gmail.com',
  testMode: false

};
sakujo commented 8 years ago

I had index.js as hook in api/hook/email/index.js... same error. I tried nodemailer directly and had same problem. So i went to gmail created an app there and installed xoauth and it worked.. i will give it a try. ty p.s. should it work without configuring anything on gmail? I mean except setting "less secure" security.

Edit: i tried and had no success. my ctrl var html = req.body.text; sails.hooks.email.send( "html", { recipientName: "Balcok Team", senderName: "Kunde", html: html }, { to: "xxxx@hotmail.de", subject: "Kundenbewertung" }, function(err) { console.log(err || "It worked!"); } )

my html.ejs is in vies/emailTemplates/html/html.ejs. my email.js in config folder looks like this: `/**

};`

Still getting the same error like in my first post.

duongNA commented 8 years ago

Hi sakujo, for gmail, we have to setup "less secure" security.

sakujo commented 8 years ago

Hi sakujo, for gmail, we have to setup "less secure" security.

It is activated.

sakujo commented 8 years ago

I had to work on other project and had no time to solve the problem. Just now i figured, that i had to set "from" and "to" to same email ( module.exports.email in config/email.js), when using gmail. Im not getting "invalid login" error anymore, but i do get "Cannot read property 'send' of undefined". Does the readme contain a typo?? I've copied from there.

`module.exports = {

'send': function(req, res) {
    console.log("in send function");

    var html = req.body.text;

        sails.hooks.email.send(
        "html",
        {
            recipientName: "Balcok Team",
            senderName: "Kunde",
            html: html
        },
        {
            to: "xxx@hotmail.de",
            subject: "Kundenbewertung"
        },
        function(err) {
            console.log(err || "It worked!");
        }
    )
}

};`

Console.log is working.

EDIT: I had deleted node_modules folder and then reinstalled it... forgot to reinstall sails-hook-email. facepalm

duongNA commented 8 years ago

cool, finally you figured out the problem. 👍

On Thu, Mar 31, 2016 at 10:31 PM, sakujo notifications@github.com wrote:

I had deleted node_modules folder and then reinstalled... forgot to reinstall sails-hook-email. facepalm

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/balderdashy/sails-hook-email/issues/26#issuecomment-203987604

Duong Nguyen Anh phone: +841668403600 skype: duongna.ict