Skip to content
Send emails in a comfortable way via models.
JavaScript Makefile
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
Readme.md
index.js
package.json

Readme.md

Mailman

Send emails in a comfortable way via models.

Installation

npm install mailman

Usage

Connecting

Mailman = require 'mailman'

Mailman.connect service: 'smtp', host: 'smtp.gmail.com', user: 'test@gmail.com', password: 'test', ssl: yes

Defining

class Notifier extends Mailman.Model
    from: 'support@newapp.com'
    subject: 'NewApp launched!'
    text: 'Yes yes yes, you heard it.'

Notifier = Mailman.setup Notifier # this is required

Sending

mail = new Notifier
mail.to = 'recipient@gmail.com'
mail.deliver (err, response) ->
    # email sent

Views

If your emails contain dynamic information, why not to use all those template engines you love?

Mailman.viewsPath = "#{ __dirname }/views"

class Notifier extends Mailman.Model
    from: 'support@newapp.com'
    subject: 'NewApp launched!'
    view: 'notifier' # Mailman will auto-guess the extension.
                     # This field is optional, class' name will be taken by default.

Notifier = Mailman.setup Notifier

mail = new Notifier
mail.to = 'recipient@gmail.com'
mail.name = 'Steve'
mail.surname = 'Jobs'
mail.deliver (err, response) ->
    # email sent

Tests

Put in your auth credentials into test/mailman.test.coffee and run mocha in Terminal.

License

MIT.

Something went wrong with that request. Please try again.