Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
xsanchezloro opened this Issue · 1 comment

2 participants

@xsanchezloro

/*
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);
                }               
            });
        };
};
@eleith
Owner

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
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.