<commit_before>// mailer.js
//
// mail-sending functionality for pump.io
//
// Copyright 2013, E14N https://e14n.com/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var _ = require("underscore"),
    email = require("emailjs");

var Mailer = {},
    maillog,
    from,
    mailopts;

Mailer.setup = function(config, log) {

    var hostname = config.hostname;

    mailopts = {
        user: config.smtpuser || null,
        password: config.smtppass || <PASSWORD>,
        host: config.smtpserver,
        port: config.smtpport || 25,
        ssl: config.smtpusessl || false,
        tls: config.smtpusetls || true,
        domain: hostname
    };

    maillog = log.child({component: "mail"}),

    maillog.info(_.omit(mailopts, "password"), "Connecting to SMTP server");

    from = config.smtpfrom || "no-reply@"+hostname;
};

Mailer.sendEmail = function(props, callback) {

    var message = _.extend({"from": from}, props),
        smtp;

    maillog.info({to: message.to || null,
                  subject: message.subject || null}, "Sending email");


    smtp = email.server.connect(mailopts);

    smtp.send(message, function(err, message) {
        if (err) {
            maillog.error({to: message.to || null,
                           subject: message.subject || null},
                          "Email error");
            callback(err, null);
        } else {
            maillog.info({to: message.to || null,
                          subject: message.subject || null},
                         "Message sent");
            callback(null, message);
        }
        smtp.close();
    });
};

module.exports = Mailer;<commit_msg>A little better output for smtp errors<commit_after>// mailer.js
//
// mail-sending functionality for pump.io
//
// Copyright 2013, E14N https://e14n.com/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var _ = require("underscore"),
    email = require("emailjs");

var Mailer = {},
    maillog,
    from,
    mailopts;

Mailer.setup = function(config, log) {

    var hostname = config.hostname;

    mailopts = {
        user: config.smtpuser || null,
        password: <PASSWORD> || <PASSWORD>,
        host: config.smtpserver,
        port: config.smtpport || 25,
        ssl: config.smtpusessl || false,
        tls: config.smtpusetls || true,
        domain: hostname
    };

    maillog = log.child({component: "mail"}),

    maillog.info(_.omit(mailopts, "password"), "Connecting to SMTP server");

    from = config.smtpfrom || "no-reply@"+hostname;
};

Mailer.sendEmail = function(props, callback) {

    var message = _.extend({"from": from}, props),
        smtp;

    maillog.info({to: message.to || null,
                  subject: message.subject || null}, "Sending email");


    smtp = email.server.connect(mailopts);

    smtp.send(message, function(err, results) {
        if (err) {
            maillog.error({to: message.to || null,
                           subject: message.subject || null,
                           message: err.message},
                          "Email error");
            callback(err, null);
        } else {
            maillog.info({to: message.to || null,
                          subject: message.subject || null},
                         "Message sent");
            callback(null, message);
        }
        smtp.close();
    });
};

module.exports = Mailer;
{'fraction_non_alphanumeric': 0.12816419612314708, 'fraction_numerical': 0.0063854047890535915, 'mean_word_length': 2.2202643171806167, 'pattern_counts': {'":': 2, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '52734', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1235, 'n_words': 373}