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 with mail.content when trying to send like the example states (documentation out of date?) #20

Closed
ff6347 opened this issue Nov 24, 2016 · 4 comments

Comments

@ff6347
Copy link

ff6347 commented Nov 24, 2016

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
@CherryNerd
Copy link
Contributor

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 

@ff6347
Copy link
Author

ff6347 commented Nov 25, 2016

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

@GreenPioneer
Copy link
Collaborator

@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 !!

@ff6347
Copy link
Author

ff6347 commented Nov 29, 2016

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.

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

No branches or pull requests

3 participants