Home

Awesome

TCS E-Mail Node Client

Build Status dependencies NPM version


This document describes the client module for the TCS e-mail service.
It is designed to simplify the requests to the service and provides a usable and expendable interface to integrate the service as easy as possible.

NPM

###Note:

MailFactory

Initialize

new MailFactory( appid [, config ] )

Creates the mail factory to send mail via the tcs mail service.

arguments

TODO Template configuraton

Methods

.config( config )

Change the configuration in operating.

arguments

Return

( Object ): the current configuration

.create()

create and return a new Mail object. This is used to define the receivers content and at least send the email.

Return

( Mail ): The Mail object as described here

.get( id )

get a single mail object.

arguments

Return

( Mail ): A Mail object.

.count()

get the count of open send mails in factory.

Return

( Number ): The count

.each( iterator )

Loop through all mail objects.

arguments

example

MailFactory.each ( id, mailObj )->
	...

.sendAll( callback )

Send all open Mails.

arguments

Mail Object methods<a id="mailobj"></a>

The Mail object can be generated by the MailFactory.mail() Method. Within this object you can define all option by using the according method.

If all options has been set you have to call the .send() method to send the mail via the tcs mail service.

Properties

Mail.id

( String )

Every mail will get a unique id to be able predefine a lot of mails and send them in bulk.

Mail.created

Timestamp the Mail object has been created. Just to be able to destroy outdated mails later.

Methods

Mail.to( mails )

Set the main TO addresses. If set to false the current TO will be cleared.

NOTE: At least one mail in to, cc or bcc has to be set.

arguments

Return

( Mail ): The Mail object self for chaining.

Mail.cc( mails )

Set the CC addresses. If set to false the current CC will be cleared

NOTE: At least one mail in to, cc or bcc has to be set.

arguments

Return

( Mail ): The Mail object self for chaining.

Mail.bcc( mails )

Set the BCC addresses. If set to false the current BCC will be cleared

NOTE: At least one mail in to, cc or bcc has to be set.

arguments

Return

( Mail ): The Mail object self for chaining.

Mail.subject( subject )

Set the subject of this mail.

NOTE: This subject has to be set. otherwise an error will be thrown during send

arguments

Return

( Mail ): The Mail object self for chaining.

Mail.reply( mails )

The Reply addresses the mail answers will send to. If set to false the current REPLY will be cleared.
If this method is not used the standard from MailFactory.config.reply will be used.

arguments

Return

( Mail ): The Mail object self for chaining.

Mail.returnPath( mail )

The return address failed mails will bounce to. If this method is not used the standard from MailFactory.config.returnPath will be used.

arguments

Return

( Mail ): The Mail object self for chaining.

Mail.html( source )

The raw mail html source to send.

arguments

Return

( Mail ): The Mail object self for chaining.

Mail.text( text )

The raw mail text to send.

arguments

Return

( Mail ): The Mail object self for chaining.

Mail.tmpl( tmplName, data [, language, type ] )

Template handling ( TODO )

Mail.send( callback )

Send this mail. If there is some missing data a error will be returned. after a successful send the Mail object will be destroyed automatically.

arguments

Mail.destroy()

Destroy the Mail object.

Example

This is a simple example to send a mail.

# create the factory
mailFactory = new MailFactory( "wmshop" )

# create a mail object
mail = mailFactory.create()

# set the data
mail.to( "abc@tcs" ).cc( [ "ghi@tcs.de", "def@tcs.de" ] )

mail.subject( "Test" )

mail.html( "<h1>My Test Mail</h1><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.</p>" )

mail.text( "My Test Mail\n\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa." )

# send the mail
mail.send ( err )=>
	if err
		console.error( err ) 
		return
	console.log( "SUCCESS" )
	return

Changelogs

VersionDateDescription
0.2.32016-03-08updated dependencies. Especially lodash to version 4
0.2.22015-12-15fixed compile error
0.2.12015-12-15updated dependencies and optimized code and environment to be used with node 4.2
0.2.02013-11-21Removed all charset settings because of a refactored server module which only allowed standard utf8
0.1.52013-11-05Small bugfix in simulation output
0.1.42013-11-05Detailed simulated output
0.1.32013-08-12fixed usage of factory configurations
0.1.22013-06-21updated dependencies
0.1.12013-06-21- implemented handling of apikey security credentials<br/>- updated tests to loady<br/>- special factory configs<br/>- added grunt mocha test module

Related Projects

NameDescription
redis-sessionsThe redis session module this middleware module is based on
tcs_node_authAuthentication module to handle login and register with a integrated mail double-opt-in logic.
node-tcs-de(Private) Sends out an email via Amazon SES.

TODOS

Ideas

NPM

The MIT License (MIT)

Copyright © 2013 Mathias Peter, http://www.tcs.de

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.