Ejemplo n.º 1
0
        connection.connect(function () {
            winston.debug('-> connected to upstream');

            connection.send({
                from: session.envelope.mailFrom,
                to: session.envelope.rcptTo,
            }, bufferStream, function (err, info) {
                connection.quit();

                if (err) {
                    winston.debug("-> error occured when forwarding the message to upstream: " + err);

                    email.error = 'Error: error occured while relaying the message';
                    saveEmail(function () {
                        callback(new Error('Error: error occured while relaying the message'));
                    });
                } else {
                    email.response = info;

                    saveEmail(function () {
                        winston.debug(info);
                        callback(null, 'Message relayed to upstream');
                    });
                }
            })
        });
Ejemplo n.º 2
0
    var sendMessage = function () {
        var envelope = mail.data.envelope || mail.message.getEnvelope();
        var messageId = (mail.message.getHeader('message-id') || '').replace(/[<>\s]/g, '');
        var recipients = [].concat(envelope.to || []);
        if (recipients.length > 3) {
            recipients.push('...and ' + recipients.splice(2).length + ' more');
        }

        this.logger.info('Sending message <%s> to <%s>', messageId, recipients.join(', '));

        connection.send(envelope, mail.message.createReadStream(), function (err, info) {
            if (returned) {
                return;
            }
            returned = true;

            connection.close();
            if (err) {
                return callback(err);
            }
            info.envelope = {
                from: envelope.from,
                to: envelope.to
            };
            info.messageId = messageId;
            return callback(null, info);
        });
    }.bind(this);
Ejemplo n.º 3
0
 connection.connect(function() {
     connection.send({
         from: '*****@*****.**',
         to: ['*****@*****.**']
     }, new Array(1024 * 1024).join('#'), function(err) {
         expect(err).to.not.exist;
         connection.quit();
     });
 });
Ejemplo n.º 4
0
 connection.connect(function() {
     connection.send({
         from: '*****@*****.**',
         to: [utf8Address]
     }, 'testmessage', function(err, status) {
         expect(err).to.not.exist;
         expect(status.accepted.length).to.equal(1);
         expect(status.rejected.length).to.equal(0);
         connection.quit();
     });
 });
Ejemplo n.º 5
0
    var sendMessage = function() {
        connection.send(data.envelope, data.message.createReadStream(), function(err, info) {
            if (returned) {
                return;
            }
            returned = true;

            connection.close();
            if (err) {
                return callback(err);
            }

            info.messageId = (data.message.getHeader('message-id') || '').replace(/[<>\s]/g, '');
            return callback(null, info);
        });
    };
    var sendMessage = function() {
        connection.send(mail.data.envelope || mail.message.getEnvelope(), mail.message.createReadStream(), function(err, info) {
            var envelope;

            if (returned) {
                return;
            }
            returned = true;

            connection.close();
            if (err) {
                return callback(err);
            }
            envelope = mail.data.envelope || mail.message.getEnvelope();
            info.envelope = {
                from: envelope.from,
                to: envelope.to
            };
            info.messageId = (mail.message.getHeader('message-id') || '').replace(/[<>\s]/g, '');
            return callback(null, info);
        });
    };