guileen / node-sendmail

send mail without setting up a SMTP server
http://guileen.github.com/node-sendmail
MIT License
560 stars 108 forks source link

Cannot get it to work #70

Closed svendeckers closed 4 years ago

svendeckers commented 4 years ago

Hi,

I have tried several setup options, but none have worked for me so far. I am using the lastest version of sendmail (1.6.1) and I'm getting these errors:

1) Setup one

const sendmail = require("sendmail")({
  silent: true,
  devPort: 465,
  devHost: 'smtp.gmail.com',
});

gives this error:

[Error] TypeError: createConnection is not a function. (In 'createConnection(devPort, devHost)', 'createConnection' is undefined)
    connectMx (0.chunk.js:194065)
    sendToSMTP (0.chunk.js:194079)
    (anonymous function) (0.chunk.js:194293)
    onceWrapper (0.chunk.js:85546)
    onceWrapper
    emit (0.chunk.js:85462)
    endReadableNT (0.chunk.js:190757)
    afterTickTwo (0.chunk.js:136552)
    run (0.chunk.js:136750)
    drainQueue (0.chunk.js:136714)

2) Setup two

const sendmail = require("sendmail")({
  silent: true,
  smtpPort: 465,
  smtpHost: 'smtp.gmail.com',
});

gives this error:

[Error] TypeError: data.sort is not a function. (In 'data.sort(function (a, b) {
          return a.priority > b.priority;
        })', 'data.sort' is undefined)
    (anonymous function) (1.chunk.js:194034)
    resolve (1.chunk.js:123194)
    connectMx (1.chunk.js:194029)
    sendToSMTP (1.chunk.js:194079)
    (anonymous function) (1.chunk.js:194293)
    onceWrapper (1.chunk.js:85546)
    onceWrapper
    emit (1.chunk.js:85462)
    endReadableNT (1.chunk.js:190757)
    afterTickTwo (1.chunk.js:136552)
    run (1.chunk.js:136750)
    drainQueue (1.chunk.js:136714)

3) Setup three

const sendmail = require("sendmail")();

gives this error:

[Error] TypeError: data.sort is not a function. (In 'data.sort(function (a, b) {
          return a.priority > b.priority;
        })', 'data.sort' is undefined)
    (anonymous function) (0.chunk.js:194034)
    resolve (0.chunk.js:123194)
    connectMx (0.chunk.js:194029)
    sendToSMTP (0.chunk.js:194079)
    (anonymous function) (0.chunk.js:194293)
    onceWrapper (0.chunk.js:85546)
    onceWrapper
    emit (0.chunk.js:85462)
    endReadableNT (0.chunk.js:190757)
    afterTickTwo (0.chunk.js:136552)
    run (0.chunk.js:136750)
    drainQueue (0.chunk.js:136714)

So, erm, help? Please? :-)

BananaAcid commented 4 years ago

require("sendmail")({ setup options})({ .. email options ..});

so you could do:

const sendmail = require("sendmail")({
// devPort ... dekim ... whatever extras you need
});

let info = await new Promise( (r,e) => sendmail({
        from: 'no-reply@mydomain.com',
        to: 'user@domain.tld',
        subject: 'test sendmail',
        html: 'Hello world.'
    }, (err,res) => r({err,res})) );

let insp = require('util').inspect;
console.log(insp(info.err), insp(info.res));
GreenPioneer commented 4 years ago

@svendeckers im just getting around to this thread - are you all good to go now ?

svendeckers commented 4 years ago

Hi @GreenPioneer , no, I needed to get it working the same day unfortunately, so I ended up using a backend with nodemailer.