Skip to content

Fix error due to: 503 bad command sequence #21

Closed
wants to merge 1 commit into from

2 participants

@ruffrey
ruffrey commented Dec 10, 2012

503 bad command sequence was creating an unhandled error.
This fixed it for me but I don't pretend to think this is the right solution.

SERVER 1:
└──503 Bad command sequence

events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: Data command failed - 503 Bad command sequence
    at SMTPClient._actionDATA (/home/jpx/mailapp/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:806:23)
    at SMTPClient._onData (/home/jpx/mailapp/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:252:29)
    at Socket.EventEmitter.emit (events.js:88:17)
    at TCP.onread (net.js:395:14)

ruffrey Fix error due to: 503 bad command sequence
503 bad command sequence was creating an unhandled error. 
This fixed it for me but I don't pretend to think this is the right solution.


SERVER 1:
└──503 Bad command sequence

events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: Data command failed - 503 Bad command sequence
    at SMTPClient._actionDATA (/home/jpx/mailapp/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:806:23)
    at SMTPClient._onData (/home/jpx/mailapp/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:252:29)
    at Socket.EventEmitter.emit (events.js:88:17)
    at TCP.onread (net.js:395:14)
628b968
@andris9
Owner
andris9 commented Dec 10, 2012

Hi, 503 is valid error and is most probably related o the configuration of your SMTP host. For example, TLS support might have been turned off but is still advertised (see ignoreTLS option to force TLS off). The server might also be rejecting empty "from" or "to"/"cc"/"bcc" address fields etc.

To see where the error is actually happening, set "debug" to true in the SMTP settings - this way all traffic between your client and the server is logged to console and you can see, what is triggering the error.

@ruffrey
@andris9
Owner
andris9 commented Dec 13, 2012

Good point - no, it should not crash the application, the mail should just be rejected with the error message. I'll look into it.

How are you using this module anyway? Is this error actually happening with Nodemailer or are you using the module directly. Could you also list the module versions used.

@ruffrey
ruffrey commented Jan 12, 2013

Sorry for the delay, this may be resolved...yes I was using it from Nodemailer. Just a test message transport sending to the first DNS mx record.

function TransportMessage(domain, messageObject, callback) {

    dns.resolveMx(domain, function(err, adr){
        if(err)
        {
            return callback(
                'MX: ' + (err.code||JSON.stringify(err)) + ' failed '.red.bold,
                {}
            );
        }
        if( !adr.length || !adr[0].exchange )
        {
            return callback(
                'MX: no MX records ' + 'failed'.red.bold,
                {}
            );
        }

        var nodemailer = require('nodemailer'),

            transport = nodemailer.createTransport("SMTP", {
                host: adr[0].exchange,
                port: 25,
                //validateRecipients: true,
                //debug: true,
                maxConnections: 1
            });


        transport.sendMail(messageObject, function(err, smtp_res) {
            transport.close(function(er){
                if(er)
                {
                    console.log('transport.close() '.red.bold, 
                        usr+'/'+c._id,
                        er
                    );
                }

                transport = null;

                callback(
                    (err ? err.name : err), 
                    smtp_res
                );
            });

        });

    });
};
@andris9 andris9 closed this Mar 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.