guileen / node-sendmail

send mail without setting up a SMTP server

Home Page:http://guileen.github.com/node-sendmail

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with mail.content when trying to send like the example states (documentation out of date?)

ff6347 opened this issue · comments

Expected Behavior

Should send mail with body defined in key html Using the text key instead of html gives the same error.

Current Behavior

var sendmail = require('sendmail')();
sendmail({
  from: 'no-reply@foo.tld',
  to: 'foo@bah.tld',
  subject: 'test sendmail',
  html: 'Mail of test sendmail '
}, function(err, reply) {
  console.log(err && err.stack);
  console.dir(reply);
});

Throws error:

/path/to/file/sendmail.js:293
    content = mail.content.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
                          ^

TypeError: Cannot read property 'replace' of undefined
    at sendmail (/path/to/file/node_modules/sendmail/sendmail.js:293:27)

Possible Solution

I switched to content for the mail body and everything worked fine. Is your documentation out of date?

Steps to Reproduce (for bugs)

  1. Use code provided in REAME.md and run it

Context

Your Environment

  • Version used: Occurs on macOS 10.12.1 and on Debian Jessie 8.5
  • Environment name and version: Node v4.6.2
  • Operating System and version (desktop or mobile): Debian and macOS

Hi @fabianmoronzirfas,

I've looked at your problem and I can't reproduce it.
My code is as followed:

var sendmail = require('sendmail')();

function mail() {
	sendmail({
		from: 'renzo@geex.company',
		to: 'development@geex.company',
		subject: 'test email',
		html: '<h1>Hello</h1><br/><h2>World!!</h2>'
	}, function (err, reply) {
		console.log(err && err.stack);
		console.dir(reply);
	});
}

mail();

And this is what I got
image

I do have to note a ticket similar to yours has been opened before.
Please try to reinstall the module.
npm uninstall sendmail && npm install sendmail

My environment is as followed:

  • Ubuntu 14.04.4 LTS
  • Node v6.1.0

npm install sendmail outputs the following:

└─┬ sendmail@1.0.0 
  └─┬ mailcomposer@3.12.0 
    ├─┬ buildmail@3.10.0 
    │ ├── addressparser@1.0.1 
    │ ├── libbase64@0.1.0 
    │ ├── libqp@1.1.0 
    │ ├── nodemailer-fetch@1.6.0 
    │ └── nodemailer-shared@1.1.0 
    └─┬ libmime@2.1.0 
      └── iconv-lite@0.4.13 

I:

  • removed the whole node_modules folder and reinstalled 👎
  • switched to node v6.5.0 removed the whole node_modules folder and reinstalled 👎
  • switched to node v6.7.0 removed the whole node_modules folder and reinstalled 👎

All give me the same error.

Currently tested on macOS 10.12.1 I will try to run a test on the Debian system ASAP

@fabianmoronzirfas Sorry for the late response its been the holidays around here.

So i looked more into it and you currently running the old version of Sendmail 0.2.2. Content is how the old code ran.

Upgrade to 1.0.0 and all the documentation will match up perfectly

let me know if you have any questions or concerns

@Geex-Renzo 👍 I appreciate having you around !!

Awesome thank you. Now it works. Was it a npm registry problem? I installed it just before I wrote the issue and got the 0.2.2 version.