1.0.10 • Published 1 year ago

ocemailsender v1.0.10

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

ocemailsender

OC Email Sender is a library to send email from a html template and using a data object to replace the placeholders in the template.

Instalation

npm install ocemailsender

Usage

const EmailSender = require('ocemailsender');
const emailSender = new EmailSender({
    smtpHost: 'smtp.gmail.com',
    smtpPort: 465,
    smtpUser: 'user',
    smtpPass: 'password'
})
const data = {
    name: 'John',
    lastname: 'Doe'
}
emailSender.sendEmail({
    from: 'no-reply@test.com',
    to: 'test@test.com',
    subject: 'Test email',
    templateUrl: 'https://test.com/test.html',
    templateHtml: '<h1>Hello <span class="name"></span> <span class="lastname"></span></h1>', // Optional if templateUrl is not provided
    data: data,
    attachments: [
        {
            filename: 'test.txt',
            content: 'Hello world!'
        }
    ]
})

Caveats

  • The template must be a html file.
  • TemplateUrl can be http:// or https:// or file://
  • If templateHtml is declared, the templateUrl will be ignored.
  • The template may have the placeholders in the format <span class="firstName">
  • Also can use handlebars format {{firstName}}
  • If subject is not specified and template have a <title> then the title will be used as subject.
  • To attach files check the nodemailer documentation
1.0.9

1 year ago

1.0.8

1 year ago

1.0.10

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago