npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tcs_node_mail_client

v0.2.2

Published

TCS node Mail Client

Downloads

3

Readme

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:

  • Regular mail attachments to mails are not possible because the mails will be signed via the DomainKeys Identified Mail (DKIM) Standard.
  • Images within the html need to be defined as link. Base64 images via styles are not valid.

MailFactory

Initialize

new MailFactory( appid [, config ] )

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

arguments

  • appid ( String ): The app id to send mails.
  • config ( Object [ optional ] ): Configuration object.
  • config.sendermail ( String ): The sender address. This could also be defined in server based on the appid
  • config.endpoint ( String [ optional; default = "http://node.tcs.de/email/send" ] ): The url to the tcs mail service.
  • config.security ( Object [ optional; default = {} ] ): If there are some security credentials within your configuration put them here. Usually Security is done by a apikey key or by using an ip filter within the server.
  • config.returnPath ( String [ optional; default = "[email protected]" ] ): Adress for returning mails.
  • config.from ( String [ optional; default = @sendermail ] ): Usually this will be the sender mail. But it's possible to us a human friendly naming.
  • config.reply ( String | Array ): A single reply address or an array of multiple addresses as standard reply. This could be overwritten by Mail.reply( mails )*
  • config.simulate ( Boolean [ optional; default = false] ): This is just a switch to prevent the final send to the mail service. It's been used to test the module. With this switch you can also turn of mail sending within your dev environment.

TODO Template configuraton

  • config.tmplLanguage ( String [ optional ] ): A standard language string like de_DE or en_US to define the language for using the template.
  • config.tmplPath ( String [ optional ] ): …
  • config.tmplType ( String [ optional ] ): …

Methods

.config( config )

Change the configuration in operating.

arguments

  • config ( Object [ optional ] ): Configuration object. Details see factory config

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

  • id ( String ): The mail id.

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

  • iterator ( Function ): Iteration method with the arguments

example

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

.sendAll( callback )

Send all open Mails.

arguments

  • callback ( Function ): Callback method called after all mails has been send.

Mail Object methods

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

  • mails ( String | Array ): A single receiver address or an array of multiple receivers.

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

  • mails ( String | Array ): A single receiver address or an array of multiple receivers.

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

  • mails ( String | Array ): A single receiver address or an array of multiple receivers.

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

  • mails ( String ): A subject string to describe the content of this mail

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

  • mails ( String | Array ): A single receiver address or an array of multiple receivers.

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

  • mails ( String ): A single return address.

Return

( Mail ): The Mail object self for chaining.

Mail.html( source )

The raw mail html source to send.

arguments

  • source ( String ): Mail html source.

Return

( Mail ): The Mail object self for chaining.

Mail.text( text )

The raw mail text to send.

arguments

  • source ( String ): Mail html source.

Return

( Mail ): The Mail object self for chaining.

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

Template handling ( TODO )

  • Should set html and text at once if defined.
  • Should handle the language

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

  • callback ( Function ): Called after the mail has been send.

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( [ "[email protected]", "[email protected]" ] )

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

|Version|Date|Description| |:--:|:--:|:--| |0.2.2|2015-12-15|fixed compile error| |0.2.1|2015-12-15|updated dependencies and optimized code and environment to be used with node 4.2| |0.2.0|2013-11-21|Removed all charset settings because of a refactored server module which only allowed standard utf8| |0.1.5|2013-11-05|Small bugfix in simulation output| |0.1.4|2013-11-05|Detailed simulated output| |0.1.3|2013-08-12|fixed usage of factory configurations| |0.1.2|2013-06-21|updated dependencies| |0.1.1|2013-06-21|- implemented handling of apikey security credentials- updated tests to loady- special factory configs- added grunt mocha test module|

Related Projects

|Name|Description| |:--|:--| |redis-sessions|The redis session module this middleware module is based on| |tcs_node_auth|Authentication 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

  • Implement a template handling solution to automatically generate the subject, html and/or text for a specific language by just call Mail.tmpl(…).to(…).send( -> )

Ideas

  • Add Attachments as S3 link

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.