Module: email-sender

The email-sender sends email to patients and labs. The module is centered around a specific config file to be created which specifies the host email from which emails are being sent, as well as when emails have to be sent and to who.
Version:
  • 0.0.3
Author:
  • Danilo Del Busso, Jacopo Madaluni, Luka Kralj

Example

Example of the config file.

{
    "transporter": {
        "host": "smtp.gotham.mail.com",  //example of SMTP host
        "port": 465,
        "secure": true, //this value true only with port 465
        "auth": {
            "user": "imnotbatman@gotham.com", //example of email
            "pass": "jokerisajoke42" //password
        }
    }
}

Methods


<async, inner> sendEmail(transporter, receiverOptions)

Send a single email based on the options
Parameters:
Name Type Description
transporter transporter the transporter from which emails are being sent
receiverOptions JSON the options of the email address to be sent, as well as the content of the mail

<async, inner> sendOneEmail(emailInfo, emailGeneratorFunction)

Generate and send a single email.
Parameters:
Name Type Description
emailInfo JSON { patient: test: hospital: carer: }
emailGeneratorFunction function Function that generates the email from emailInfo.
Returns:
True if email was successfully sent, false if something went wrong.
Type
boolean

<async, inner> sendOverdueReminderToHospital(emailInfo)

Send a single reminder to hospital.
Parameters:
Name Type Description
emailInfo JSON { patient: test: hospital: carer: }
Returns:
True if email was successfully sent, false if something went wrong.
Type
boolean

<async, inner> sendOverdueReminderToPatient(emailInfo)

Send a single reminder to patient.
Parameters:
Name Type Description
emailInfo JSON { patient: test: hospital: carer: }
Returns:
True if email was successfully sent, false if something went wrong.
Type
boolean

<async, inner> sendReminderToHospital(emailInfo)

Send a single reminder to hospital.
Parameters:
Name Type Description
emailInfo JSON { patient: test: hospital: carer: }
Returns:
True if email was successfully sent, false if something went wrong.
Type
boolean

<async, inner> sendReminderToPatient(emailInfo)

Send a single reminder to patient.
Parameters:
Name Type Description
emailInfo JSON { patient: test: hospital: carer: }
Returns:
True if email was successfully sent, false if something went wrong.
Type
boolean

<inner> sleep(ms)

Await for this function to pause execution for a certain time.
Parameters:
Name Type Description
ms number Time in milliseconds
Returns:
Type
Promise