Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

QUIT command is not always sent when sending multi-part messages #60

Closed
xsanchezloro opened this Issue Feb 7, 2013 · 1 comment

Comments

Projects
None yet
2 participants

/*
Client does not send QUIT command (although it says so when using debug mode, but it does not appear in network sniffer) unless

The following code works, we need to recreate the connection to server:

email.server.connect({
host: "localhost",
port: 5001,
ssl: false
});

each time to be succesful, thus forcing client sending the QUIT command
*/

email_connect.composeAndSendMail = function(  replacements, message_body, callback) {
    var email_connect= email.server.connect({
        host: "localhost",
        port: 5001,
        ssl: false
    });
    var process_email = function(err, email_template) {
            if(err) {
                return callback(err);
            }

            _.each(replacements, function(replacement) {
                email_template = email_template.replace(replacement.key, replacement.value);
            });

            message_body.text = email_template;
            message_body.attachment = [
                {
                    data: email_template,
                    alternative: true
                }
            ];
            email_connect.send(message_body, function(err, message) {
                if(err) {
                    console.log("Error sending email");
                    callback(err, null);
                }else{
                    callback(null, message);
                }               
            });
        };
};

/*
This code presents the bug after several executions
*/

var email_connect= email.server.connect({
        host: "localhost",
        port: 5001,
        ssl: false
    });

email_connect.composeAndSendMail = function(  replacements, message_body, callback) {

    var process_email = function(err, email_template) {
            if(err) {
                return callback(err);
            }

            _.each(replacements, function(replacement) {
                email_template = email_template.replace(replacement.key, replacement.value);
            });

            message_body.text = email_template;
            message_body.attachment = [
                {
                    data: email_template,
                    alternative: true
                }
            ];
            email_connect.send(message_body, function(err, message) {
                if(err) {
                    console.log("Error sending email");
                    callback(err, null);
                }else{
                    callback(null, message);
                }               
            });
        };
};
Owner

eleith commented Jul 6, 2014

i still wasn't able to replicate given the code you suggested, but i did find a few places where quit was being set, but no response was waited for.

this might lead to the scenario you were describing. i have pushed through a commit so now when quit is sent, it should be actually sent before any closing of the connection.

@eleith eleith closed this Jul 6, 2014

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