Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 347461e976
Fetching contributors…

Cannot retrieve contributors at this time

68 lines (46 sloc) 1.319 kB

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.

Jump to Line
Something went wrong with that request. Please try again.