Internships manager

Internships manager

  • Docs
  • API
  • Tuto
  • Help
  • GitHub

›Services

Get started

  • Installation
  • Settings

Services

  • Mailer service

Software architecture

  • Back end part
  • Front end part

Mailer service

Configuration

The mailer service use the module nodemailer to handle transport in back-end. To configure you'r SMTP connexion, please fill all environements vars in services/.env files prefixed by SMTP_.

NameCommentTypesDefault
SMTP_HOSTSMTP Hoststringsmtp.ethereal.email
SMTP_PORTSMTP Portinteger587
SMTP_SECURESMTP Securebooleanfalse
SMTP_AUTH_USERSMTP Auth userstring/
SMTP_AUTH_PASSSMTP Auth passstring/

Usage

To use this service, you only need to import expected template in your program as following

import { sendWelcome } from 'src/emails';

sendWelcome().then((sent) => {
    ...
}).catch((e) => {
    ...
})

Developpement

To develop this service, you could add a template under services/src/emails/templates/ using following protocol:

  • Create a directory with your template name
  • Create html.pug witch extends services/src/emails/templates/base/html.pug file.
extends ../base/html.pug

block content
    ... your content
  • Create subject.pug for the email subject
= `[STAGES] YOUR SUBJECT`
  • Create text.pug for the email text. This file is used to attach to the sent email a text for non-html mailbox.
  • Add to services/src/emails/base.ts a function to send your email.
/**
 * @summary Method used to send YOUR_TEMPLATE_NAME message to user
 * @param {string} to Dest user
 * @returns {Promise<string>} Resolve: send message
 */
export function sendYOUR_TEMPLATE_NAME(to: string): Promise<string> {
    return email.send({
        template: path.join(__dirname, 'templates', 'YOUR_TEMPLATE_NAME'),
        message: { to },
        locals: {},
    });
}
← SettingsBack end part →
  • Configuration
  • Usage
  • Developpement
Copyright © 2019 ENIB