Skip to content
Snippets Groups Projects
Select Git revision
  • teachers-ies
  • homologa protected
  • development protected
  • instruction_level_fix2
  • enrollment_rate
  • master default protected
  • hotfix-enrollment-aggregate
  • instruction_level_fixes
  • docentes-ies-ente-federativo
  • receita-potencial
  • #974-receita-potencial
  • db-conn
  • years-of-study-mean
  • new-indicators
  • issue_935
  • instruction_number
  • issue_958
  • issue_953
  • issues_indicadores_agregados
  • courseAggregate
  • v1.16.0
  • v1.15.1
  • v1.14.2
  • v1.14.1
  • v1.14.0
  • v1.14
  • v1.9.0
  • v1.8.3
  • v1.8.2
  • v1.8.1
  • v1.8.0
  • v1.7.0
  • v1.6.1
  • v1.6.0
  • v1.5.0
  • v1.4.2
  • v1.4.1
  • v1.4.0
  • v1.3.3
  • v1.3.2
40 results

email.js

Blame
  • email.js 985 B
    const libs = `${process.cwd()}/libs`;
    const log = require(`${libs}/log`)(module);
    const config = require(`${libs}/config`);
    const nodemailer = require('nodemailer');
    const htmlToText = require('nodemailer-html-to-text').htmlToText;
    
    let transporter = nodemailer.createTransport({
        host: config.email.host,
        port: config.email.port,
        secure: config.email.secure,
        ignoreTLS: config.email.ignoreTLS
    });
    
    transporter.use('compile', htmlToText());
    
    // verify connection configuration
    transporter.verify(function(error, success) {
       if (error) {
            log.error(error);
       } else {
            log.info('Email server is ready to take our messages');
       }
    });
    
    const mailOptions = {
        from: config.email.from,
        to: config.email.from
    };
    
    module.exports = function send(options, cb) {
        let opt = Object.assign({}, mailOptions, options);
        transporter.sendMail(opt, (err, info) => {
            if(err) {
                return cb(err);
            }
            cb(null, info);
        });
    };