Comailer
A simple CO wrapper around
yield
Nodemailer from co or koa!
CoffeeScript (is optional, see javascript below)
'use strict' co = require 'co' comailer = require 'comailer' transporter = comailercreateTransport service: 'gmail' auth: user: 'sender@gmail.com' pass: 'password' co -> # yielding can throw errors you could try/catch or bail out try result = yield transportersendMail from: 'sender@address' to: 'receiver@address' subject: 'hello' text: 'hello world!' consolelog result catch error consoleerror errorstack # if you need to still need to call without yielding: thunkOfSendMail = transportersendMail from: 'sender@address' to: 'receiver@address' subject: 'hello' text: 'hello world!' #... thunkOfSendMail if error consoleerror errorstack else consolelog result
Javascript
'use strict' var co = ; var comailer = ; var transporter = comailer; ; // if you need to still need to call without yielding using the returned thunk directly: thunkOfSendMail = transporter; //... ;