Code Monkey home page Code Monkey logo

nodemailer's Issues

fallback to HELO not work

when use Nodemailer with SMTP server that not implement EHLO like https://github.com/euangoddard/node-smtpevent, error has occurred.

/home/snj14/dev/node/mailtest/node_modules/nodemailer/lib/smtp.js:575
         if(data.match(/PIPELINING/i)){
                 ^
 TypeError: Cannot call method 'match' of null
    at SMTPClient. (/home/snj14/dev/node/mailtest/node_modules/nodemailer/lib/smtp.js:575:17)
    at Object.callback (native)
    at SMTPClient._dataListener (/home/snj14/dev/node/mailtest/node_modules/nodemailer/lib/smtp.js:466:20)
    at SMTPClient. (/home/snj14/dev/node/mailtest/node_modules/nodemailer/lib/smtp.js:645:14)
    at Socket. (native)
    at Socket.emit (events.js:64:17)
    at Socket._onReadable (net.js:678:14)
    at IOWatcher.onReadable [as callback] (net.js:177:10)

inserting return; after HELO code blocks, seemed to do the trick.

mimelib dependency

Wrong enconding because is (suspect) "mimelib-noiconv":"*", until friday (0.1.3) was another version and now (0.1.4) is broken.

has no method 'createTransport'

Hello,
I found this error when I launch the app.

        var transport = nodemailer.createTransport("Sendmail", "/usr/sbin/sendmail")
                             ^
TypeError: Object # has no method 'createTransport'

I appreciate any help.
Thanks,
Alex

SMTP client keeps listening on timeout errors

Hey Andris,

First of all, nice work mate!

I was just trying out Nodemailer for sending SMTP messages (not using auth, but directly to Gmail on port 25) and found out that when a timeout error occurs, the SMTP connection is not closed so the result is that the node process keeps running forever. After a while, the client tries to resend the message but always throws a "connect Unknown system errno 110" exception.

As far as I tested, the only way to fix this was to forcefully destroy() the connection on the SMTPClient.prototype.close() method. I thought of forking and sending a pull request but I'm not sure if that's the best solution -- besides, it's just one line of code. :)

That's all mate, thanks again.

Setting the sending engine globally is prone to error

i.e.

nodemailer.sendmail = true;
nodemailer.SMTP = { host: 'localhost' };

We are using nodemailer on a large project for a major UK Newspaper and have a team to 6 developers working on the same project.

All HTML emails had passed the manual QA process and worked in all mail clients on launch.

There was a minor update and a developer required nodemailer for an alert email and set the engine to sendmail. This then made all instances of nodemailer send via that transport. But as sendmail only causes html email problems in Hotmail (https://github.com/andris9/Nodemailer/issues/44) the problem went undetected.

One work around is to call nodemailer.SMTP = { host: 'localhost' }; before each send but that isn't very nice.

On a major version number update it would be great if you considered removing this in favor of per instance setting. I'd be happy to submit pull request if you agree this would be a better solution.

Here is a gist which shows the problem: https://gist.github.com/1205774

Regards

Paul

http://yuiblog.com/blog/2006/06/01/global-domination/

Missing stripHtml

Previous versions generated a plain text alternative when only given a HTML body. In 0.3 this disappeared, the whole regex magic used there has gone.

It would be great to have that feature back.

Mechanism for sending in batches?

When sending emails to multiple recipients, is there any way to avoid multiple connection setups/teardowns? Would that even be possible? Maybe SMTP requires a new connection for each "send" operation...

Remove SMTP logic from EmailMessage

I have a preliminary change that does this, but wanted to bring up some discussion. EmailMessages currently contain the SMTP command pipeline for FROM TO and DATA. This makes it very hard to reuse SMTPClients which may stay open for a long time. There are 2 real alternative solutions:

  • Make EmailMessages accept a client while sending.
  • Remove the SMTP logic from EmailMessage and put it into SMTPClient.

I think the latter makes more sense since you can still give a message to a client after that and will not change the API terribly to the end developer. Ontop of this, the reuse of SMTPClients is a frequent action if you are running services.

This has a side effect of meaning there is a need for message queueing and events.

  • "empty" event when the client has flushed all the messages to a server.
  • _messageQueue for when you have errors to see which messages were left (sending mail callbacks should also fire errors)

This does let us do some things like SMTPClient pooling.

Sending MAIL command twice

When talking to a Python SMTP server (i.e. using stmpd.py), the MAIL command is sent twice, which is illegal SMTP. Nodemailer v0.1.9 and Node v0.4.2.

mailer.send_mail({
    //debug: true,
    html: 'Test',
    sender: '[email protected]',
    subject: 'Subject',
    to: '[email protected]'
},function(err, success) {
    if (success) {
        util.log('[INFO] Email sent');
    }
    else {
        // this happens on every error, not just once per attempt
        util.log('[ERROR] Failed to send email: ' + JSON.stringify(err.message || err));
    }
});

generates the following output:

CONNECTION: 220 localhost Python SMTP proxy version 0.2
Connection established!
SEND:
"EHLO [127.0.0.1]\r\n"
RECEIVE:
"502 Error: command \"EHLO\" not implemented\r\n"
SEND:
"HELO [127.0.0.1]\r\n"
SEND:
"MAIL FROM:<[email protected]>\r\n"
RECEIVE:
"250 localhost\r\n"
SEND:
"MAIL FROM:<[email protected]>\r\n"
RECEIVE:
"250 Ok\r\n"
SEND:
"RCPT TO:<[email protected]>\r\n"
RECEIVE:
"503 Error: nested MAIL command\r\n"
17 Mar 16:31:38 - [ERROR] Failed to send email: "503 Error: nested MAIL command"

Accept Streams for content?

For larger attachments and messages sending 10+Mb can cause jitters in node apps. Would it be possible to support streams, and if so, how would we detect streams?

qmail

I was wondering if this package had been used successfully with a quail based system. I get a message failed error. I can get it to work with Marak's mailer, but I'd like to use the HTML feature of this package.

Thanks.

should handle null callbacks

with no callback I get :

/usr/local/lib/node/.npm/nodemailer/0.1.8/package/lib/mail.js:508:25

sometimes you're not interested in the outcome of the callback: maybe set it as a noop function

SES Signature Calculations

I may be doing something wrong, but since the configuration is dead simple I figured I would post this.

I am consistently getting the following error with a 403:
SignatureDoesNotMatch
The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.

I have modified the AWSAccessKeyID and AWSSecretKey variables in the /nodemailer/examples/example_ses.js and am running it directly.

Mind you, if I purposefully mess up the key and keyID I get a login error.

child_process not implemented for windows node.js

But I should be able to send mail not using sendmail.
my work around is:

// use sendmail if set
if(exports.sendmail){
      if(process.platform=="win32"){
            console.log("Sendmail unsupported in windows");
      }else{
      var   exec = require('child_process').exec;
    var headers = this.generateHeaders(),
        body = this.generateBody();

    var path = typeof exports.sendmail=="string"?exports.sendmail:"sendmail";
    exec('echo "'+(headers+"\r\n\r\n"+body).replace(/"/g,'\\"')+'" | '+path+" -t", function(error){
        process.nextTick(function(){
            if(error){
                callback && callback(error, null);
            }else{
                callback && callback(null, true);
            }
        });
    });
   return;
 }

ReadMe Error

You have console.log('Message ' + success ? 'sent' : 'failed'); in a few places in the README example codes. That should be changed to console.log('Message ' + (success ? 'sent' : 'failed')); due to operator precedence.

STARTTLS connection: 503 Command sequence error + fix

I'm connecting to the SMTP server at 1and1 internet. Here is the debug output:

CONNECTION (1): 220 smtp.perfora.net (mrus4) Welcome to Nemesis ESMTP server
Connection established! (1)
SEND (1):
└──"EHLO [127.0.0.1]\r\n"
RECEIVE (1):
└──"250-smtp.perfora.net\r\n" ""
RECEIVE (1):
└──"250-STARTTLS\r\n250-AUTH LOGIN PLAIN\r\n250-AUTH=LOGIN PLAIN\r\n250-PIPELINING\r\n250-SIZE 120000000\r\n250 HELP\r\n" "250-smtp.perfora.net\r\n"
Routing Data (1)
STARTTLS: (1)
SEND (1):
└──"STARTTLS\r\n"
RECEIVE (1):
└──"220 OK\r\n" "250-smtp.perfora.net\r\n"
Routing Data (1)
RECEIVE (1):

...... Certificate data ..........

SEND (1):
└──"AUTH PLAIN bxxxxxxxxx==\r\n"
RECEIVE (1):
└──"503 Command sequence error\r\n" ""

I think that this is related to issue #18, where the server needs another EHLO to get going. I got the latest code, but the additional HELO was not being sent.

I debugged a little and discovered that the connection was 'authorized' so the callback was not being made. Here is the patch that got things working for me:

diff --git a/lib/smtp.js b/lib/smtp.js
index 8a65724..65ba8a8 100644
--- a/lib/smtp.js
+++ b/lib/smtp.js
@@ -532,7 +532,7 @@ SMTPClient.prototype._starttlsHandler = function(callback){
this.ignore_data = false;
this._data_remainder = "";
this.emit("connection_stable");

  •        if(!this._connection.authorized && this.options.use_authentication) {
    
  •        if(this._connection.authorized && this.options.use_authentication) {
             callback();
         }
    

I don't know if this breaks any other scenarios, but the change gets TLS working for me.

Error being emitted from SMTPClient.prototype._handshakeListener, mail still sends

Im connecting to Microsoft Exchange servers, and it's extremely important that these emails send. Well, because of that, I check the result of the send and wait 10 seconds if it fails to try again. Problem being, I'm getting multiple emails. I'd think if the connection times out, as indicated below, that the email wouldn't send, but it appears that it is.

{ 
    stack: [Getter/Setter],
    arguments: undefined,
    type: undefined,
    message: 'Server responded with 451 Timeout waiting for client input' 
}
Trace: 
    at SMTPClient.<anonymous> (/usr/local/lib/node/.npm/nodemailer/0.1.7/package/lib/mail.js:459:21)
    at SMTPClient.emit (events.js:42:17)
    at SMTPClient.<anonymous> (/usr/local/lib/node/.npm/nodemailer/0.1.7/package/lib/smtp.js:289:18)
    at SMTPClient._onData (/usr/local/lib/node/.npm/nodemailer/0.1.7/package/lib/smtp.js:363:18)
    at Socket.<anonymous> (native)
    at Socket.emit (events.js:42:17)
    at Socket._onReadable (net.js:649:14)
    at IOWatcher.onReadable [as callback] (net.js:156:10)

Tls ?

Can send using TLS

SMTP Configured
Sending Mail

Nodemailer, 0.1.13; +http://www.nodemailer.org: 1

CONNECTION (1): 220 SAPO.pt PTMailServer ESMTP SPF1
Connection established! (1)
SEND (1):
└──"EHLO sl.pt\r\n"
RECEIVE (1):
└──"250-SAPO.pt PTMailServer\r\n250-AUTH LOGIN PLAIN\r\n250-AUTH=LOGIN PLAIN\r\n250-PIPELINING\r\n250-STARTTLS\r\n250-SIZE 0\r\n250 8BITMIME\r\n" ""
Routing Data (1)
STARTTLS: (1)
SEND (1):
└──"STARTTLS\r\n"
RECEIVE (1):
└──"220 ready for tls\r\n" ""
Routing Data (1)
RECEIVE (1):
└──"\u0016\u0003..(truncated).\u0000" ""

Uncaught Exception TypeError: Cannot call method 'verifyError' of undefined
at SecurePair. (/home/jpaulo/Desktop/testes/ptmailAlert/node_modules/nodemailer/lib/starttls.js:24:37)
at SecurePair.emit (events.js:61:17)
at SecurePair.maybeInitFinished (tls.js:598:10)
at CleartextStream._push (tls.js:269:17)
at SecurePair.cycle (tls.js:574:20)
at EncryptedStream.write (tls.js:96:13)
at Socket.ondata (stream.js:36:26)
at Socket.emit (events.js:81:20)
at Socket._onReadable (net.js:678:14)
at IOWatcher.onReadable as callback

Adding templating functionality

I'm considering adding templating functionality to Nodemailer (similar as it is with node_mailer). Not reaaly sure yet, what would be the best way for it.

Probably something in the lines of

// create template
myTemplate = nodemailer.createTemplate({
    engine: "mustache",
    templateFile: "/path/to/file"
});

// setup mail options with template
mailOptions = {
    ...,
    html: myTemplate({
        name: "Santa Claus",
        title: "mr.",
        phone: "+1 (234) 567 8901"
    })
}

The returned template value would be a function that takes template options as a parameter and returns a paused Stream object, that will start rendering on stream.resume(). Currently html and text options do not accept streams as input but this should not be very hard to change.

EPERM at Socket._onConnect

Same code as as https://github.com/andris9/Nodemailer/issues#issue/13 but this time pointed at a remote SMPT server that I can access perfectly via telnet. Node v0.4.2 built on cygwin.

host and port have been set thus:
mailer.SMTP = {
host: 'smtp.bar.com',
port: 25
};

The error returned through the callback is:
Error: EPERM, Operation not permitted
at Socket._onConnect (net.js:576:18)
at IOWatcher.onWritable (net.js:165:12)

Microsoft Exchange with high amount of To

I have a company intranet that I'm working with, sending emails to an internal SMTP server. There are multiple Exchange servers, 2007 and 2010 primarily. I ran into an issue when sending to multiple recipients that caused the headers to be displayed in the body portion of the email. It appears that Exchange has trouble with the To: portion of the headers being too long. I fixed the issue by wrapping with \r\n\t after 2 emails in the EmailMessage.prototype.generateAddresses function in lib/mail.js.

subject is not escaped

Use Case:

subject = '[Support] ' + message.slice(0, 40) + '...'

Suppose that message is

"Hey,\nBob here."

Characters such as newlines which are not allowed in the subject should be escaped or replaced

"Hey, Bob here." // preferred

or

"Hey,\\nBob here." // accurate, catches developers attention

Content disposition inline

Embeddable files need not to be content-disposition: inline but attachment. Inline means that the file will be shown where defined.

Cant find mimelib-noiconv?

I try to use Nodemailer, but it can not find the mentioned library.

I am on windows, so i cant install it via npm. Tried to search for the library but couldn't find any.
What should I do?

how can I send a image as attachment

As the title said,I can't send a image as attachement. and my code is like this:
var attachment = [
{
'filename':'cat.jpg',
'contents': new Buffer('img',encoding='ascii'),
}
];

mail.send_mail(
{
sender:'[email protected]',
to:'[email protected]',
subject:'none',
attachments: attachment,
body:'a attachment'
},

I tried every kind of encoding,and all failed.
please help me to figure out this problem.

Message failed: 503 AUTH command used when not advertised

nodemailer.SMTP = {
    host: "mail.example.com",
    port: 587, 
    use_authentication: true,
    user: "[email protected]",
    pass: "examplepass"
}

I'm using above setting and send through Exim MTA . The error appear : Message failed: 503 AUTH command used when not advertised . After doing some research, maybe

  1. Exim 4 requires that AUTH command only be sent after the client issued EHLO - attempts to authenticate without EHLO would be rejected.
  2. That is, AUTH command could not be used unless advertised (through EHLO,
    according to auth_advertise, etc). This behavior was hardened in Exim
    4.20 and is not an option.

I hope this can help you guys debug on this issue.

None

This issue should be deleted. Doesn't belong here.

Callback of send_mail is never called.

Hello,

It looks like the callback of send_mail is not called.
My use case is example.js with the Gmail SMTP. The mail is correctly sent but the callback function is never called. Any idea where to look for the issue?

not waiting 220 from server before first EHLO

Hi there

I dont know is this is official SMTP protocol behavior or another exim4 requirement...

Look like nodemailer doesnt wait for the server GREETING before sending the first EHLO which breaks in some case with exim4 smtp.

this could ends up with errors like this (exim log) :

2011-12-26 19:32:15 SMTP protocol synchronization error (input sent without waiting for greeting): rejected connection from H=localhost [127.0.0.1] input="EHLO xxxxx.kimsufi.com\r\n"

smtp.js log :

SEND:
"EHLO xxxxxx.kimsufi.com\r\n"
RECEIVE:
"554 SMTP synchronization error\r\n"
--> mail error: [Error: Server responded with 554 SMTP synchronization error]

with a little timeout it works, but looks dirty to me... ny better idea ?

Thanks !

TypeError: Object #<an Object> has no method 'hostname'

version 0.1.7 has an issue with node 0.3.2 where it calls require('os').hostname().

unfortunately in 0.3.2, this method is 'getHostname'.

users my be able to get around this with

oslib = require('os')
if not oslib.hostname?
  oslib.hostname = oslib.getHostname

Trouble installing 0.1.18 via npm

I am getting tar: Unexpected EOF in archive on the npm package for 0.1.18, which doesn't happen for 0.1.17 - is it just me or the 0.1.18 npm is corrupt?

Multiple configuration profiles

Currently we configure it like this:

nodemailer.SMTP = {
    host: 'smtp.example.com'
}

How about if we could do this (optionally):

nodemailer.SMTP = [] // array
nodemailer.SMTP.push(config.email.host1); // host1 conf is same as normal conf but with name: key
nodemailer.SMTP.push(config.email.host2); // ditto

Then when sending email, we say:

nodemailer.profile('host1').send_email(yada yada);

the profile method would be chainable and would switch the SMTP host configuration on the fly.

What do you think? If there's a better way, sure, please tell me. If this way seems ok, I might give it a shot one of these days. I really need this feature anyway.

Changing timeout?

I keep getting ECONNRESET when I try to use my Gmail SMTP to send emails and I think that it depends on some timeout being exceeded.

Is there a way I could change the timeout?

Repeated failure to send mail over Gmail SMTP

I'm using a Google Apps account to send email (well, to try sending anyway). Here's the code I use to send the email. I use this configuration:

  user: '[email protected]',
  pass: 'password',
  ssl: true,
  host: 'smtp.gmail.com',
  use_authentication: true,
  port: 465

I've also set the sender to 'Our Team [email protected]' (i.e., not just email). Rest of the code is a bit longish, so I won't quote here. In essence, I load a template from file, and interpolate data into it. That's why I have a wrapper module that takes care of this[1].

I've got some recursive function that calls the wrapper method until it can successfully send the email (or when it has tried 4 times with increasing time intervals between the tries). All tries fail. Every time, there is no error message, but sent is always false.

How can I troubleshoot this issue? Is it an issue at all?

[1] https://gist.github.com/1113923

Is SMTP required?

I'm wondering if I have to setup SMTP just to send mail using the default server postfix setup. I'm trying to move from mailing use bash or PHP to node.js. Can this package call a command-line mail -s "something" -m "message" [email protected] or something and skip the SMTP stuff?

Or am I thinking about this wrong?

Problem with line break in "body:"

If you try to send a message with line breaks

"Hello!

How are you!?

Cheers!"

Occour an error!

The same message:

"Hello! \n\nHow are you!?\n\nCheers!"

Its ok!

Can you fix it!? Thanks!

html is broken

Everything was working as expected but suddenly 'npm update' broke html messages, now this mail does not contain any html at all. Only the plain text is visible, what's wrong?

new nodemailer.send_mail({
    sender : 'test <[email protected]>',
    to : [email protected]'
    subject : 'process exited abnormally',
    body : 'unformatted text',
    html : '<strong>this is a <em>formatted</em> text</strong>'
},function(err, msg) {
    if (err) util.log('Error sending email: ' + err.toString());
});

EDIT:

Even new lines get removed using plain text.

I'm using a gmail account.

Unable to send email through gmail

Hey guys,

Just started using the module with nodejs 0.4.10 to do some simple emailing, but I haven't been able to send an email due to the following error:

Error: 530-5.5.1 Authentication Required. Learn more at                              
530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 a9sm3071219icy.6

Before you ask, yes I'm sure my username and password are correct. Anyways, here's the relevant code I'm using:

var nodemailer = require('nodemailer');
nodemailer.SMTP = {
    debug: true,
    host: 'smtp.gmail.com',
    port: 465,
    ssl: true,
    user_authentication: true,
    user: '[email protected]',
    pass: 'mypassword'
};

var testMail = {
    sender: '[email protected]',
    to: '[email protected]',
    subject: 'test 1 2 3',
    body: 'cool!'
};

nodemailer.send_mail(testMail, function(err, success) {
    if (err) {
        console.log('Error msg: ' + err);
    }
    else {
        console.log('Success msg: ' + success);
    }
});

Transport.close() callback breaks examples

With the new callback parameter in Transport.close() as of 2/10, the examples in README.md break because the callback is undefined.

TypeError: undefined is not a function
    at Transport.close (./node_modules/nodemailer/lib/transport.js:71:9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.