',
-
- // Subject of the message
- subject: 'Nodemailer is unicode friendly ✔', //
-
- // plaintext body
- text: 'Hello to myself!',
-
- // HTML body
- html: 'Hello to myself 
' +
- 'Here\'s a nyan cat for you as an embedded attachment:

',
-
- // An array of attachments
- attachments: [
-
- // String attachment
- {
- fileName: 'notes.txt',
- contents: 'Some notes about this e-mail',
- contentType: 'text/plain' // optional, would be detected from the filename
- },
-
- // Binary Buffer attachment
- {
- fileName: 'image.png',
- contents: new Buffer('iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/' +
- '//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U' +
- 'g9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC', 'base64'),
-
- cid: 'note@node' // should be as unique as possible
- },
-
- // File Stream attachment
- {
- fileName: 'nyancat.gif',
- filePath: __dirname + "/nyan.gif",
- cid: 'nyan@node' // should be as unique as possible
- }
- ]
+// setup e-mail data with unicode symbols
+var mailOptions: nodemailer.SendMailOptions = {
+ from: 'Fred Foo ✔ ', // sender address
+ to: 'bar@blurdybloop.com, baz@blurdybloop.com', // list of receivers
+ subject: 'Hello ✔', // Subject line
+ text: 'Hello world ✔', // plaintext body
+ html: 'Hello world ✔' // html body
};
-console.log('Sending Mail');
-
-transport.sendMail(message, function (error) {
- if (error) {
- console.log('Error occured');
- console.log(error.message);
- return;
- }
- console.log('Message sent successfully!');
+// send mail with defined transport object
+transporter.sendMail(mailOptions, (error: Error, info: nodemailer.SentMessageInfo): void => {
+ // nothing
});
-// From the SMTP section of https://npmjs.org/package/nodemailer README
-
-var smptTransport1: Transport = nodemailer.createTransport("SMTP", {
- service: "Gmail", // sets automatically host, port and connection security settings
- auth: {
- user: "gmail.user@gmail.com",
- pass: "userpass"
- }
-});
-
-var smtpTransport2: Transport = nodemailer.createTransport("SMTP", {
- host: "smtp.gmail.com", // hostname
- secureConnection: true, // use SSL
- port: 465, // port for secure SMTP
- auth: {
- user: "gmail.user@gmail.com",
- pass: "userpass"
- }
-});
-
diff --git a/nodemailer/nodemailer-types.d.ts b/nodemailer/nodemailer-types.d.ts
new file mode 100644
index 000000000..bffa6b301
--- /dev/null
+++ b/nodemailer/nodemailer-types.d.ts
@@ -0,0 +1,149 @@
+// Type definitions for Nodemailer 1.3.2
+// Project: https://github.com/andris9/Nodemailer
+// Definitions by: Rogier Schouten
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module nodemailer {
+
+ export interface AttachmentObject {
+ /**
+ * filename to be reported as the name of the attached file, use of unicode is allowed
+ */
+ filename?: string;
+ /**
+ * optional content id for using inline images in HTML message source
+ */
+ cid?: string;
+ /**
+ * Pathname or URL to use streaming
+ */
+ path?: string;
+ /**
+ * String, Buffer or a Stream contents for the attachment
+ */
+ content: string|Buffer|NodeJS.ReadableStream;
+ /**
+ * If set and content is string, then encodes the content to a Buffer using the specified encoding. Example values: base64, hex, 'binary' etc. Useful if you want to use binary attachments in a JSON formatted e-mail object.
+ */
+ encoding?: string;
+ /**
+ * optional content type for the attachment, if not set will be derived from the filename property
+ */
+ contentType?: string;
+ /**
+ * optional content disposition type for the attachment, defaults to 'attachment'
+ */
+ contentDisposition?: string;
+ }
+
+ export interface SendMailOptions {
+ /**
+ * The e-mail address of the sender. All e-mail addresses can be plain 'sender@server.com' or formatted 'Sender Name ', see here for details
+ */
+ from?: string;
+ /**
+ * An e-mail address that will appear on the Sender: field
+ */
+ sender?: string;
+ /**
+ * Comma separated list or an array of recipients e-mail addresses that will appear on the To: field
+ */
+ to?: string|string[];
+ /**
+ * Comma separated list or an array of recipients e-mail addresses that will appear on the Cc: field
+ */
+ cc?: string|string[];
+ /**
+ * Comma separated list or an array of recipients e-mail addresses that will appear on the Bcc: field
+ */
+ bcc?: string|string[];
+ /**
+ * An e-mail address that will appear on the Reply-To: field
+ */
+ replyTo?: string;
+ /**
+ * The message-id this message is replying
+ */
+ inReplyTo?: string;
+ /**
+ * Message-id list (an array or space separated string)
+ */
+ references?: string|string[];
+ /**
+ * The subject of the e-mail
+ */
+ sbject?: string;
+ /**
+ * The plaintext version of the message as an Unicode string, Buffer, Stream or an object {path: '...'}
+ */
+ text?: string|Buffer|NodeJS.ReadableStream|AttachmentObject;
+ /**
+ * The HTML version of the message as an Unicode string, Buffer, Stream or an object {path: '...'}
+ */
+ html?: string|Buffer|NodeJS.ReadableStream|AttachmentObject;
+ /**
+ * An object or array of additional header fields (e.g. {"X-Key-Name": "key value"} or [{key: "X-Key-Name", value: "val1"}, {key: "X-Key-Name", value: "val2"}])
+ */
+ headers?: any;
+ /**
+ * An array of attachment objects (see below for details)
+ */
+ attachments?: AttachmentObject[];
+ /**
+ * An array of alternative text contents (in addition to text and html parts) (see below for details)
+ */
+ alternatives?: AttachmentObject[];
+ /**
+ * optional Message-Id value, random value will be generated if not set
+ */
+ messageId?: string;
+ /**
+ * optional Date value, current UTC string will be used if not set
+ */
+ date?: Date;
+ /**
+ * optional transfer encoding for the textual parts (defaults to 'quoted-printable')
+ */
+ encoding?: string;
+ }
+
+ export interface SentMessageInfo {
+ /**
+ * most transports should return the final Message-Id value used with this property
+ */
+ messageId: string;
+ /**
+ * includes the envelope object for the message
+ */
+ envelope: any;
+ /**
+ * is an array returned by SMTP transports (includes recipient addresses that were accepted by the server)
+ */
+ accepted: string[];
+ /**
+ * is an array returned by SMTP transports (includes recipient addresses that were rejected by the server)
+ */
+ rejected: string[];
+ /**
+ * is an array returned by Direct SMTP transport. Includes recipient addresses that were temporarily rejected together with the server response
+ */
+ pending?: string[];
+ /**
+ * is a string returned by SMTP transports and includes the last SMTP response from the server
+ */
+ response: string;
+ }
+
+ /**
+ * This is what you implement to create a new transporter yourself
+ */
+ export interface Transport {
+ name: string;
+ version: string;
+ send(mail: SendMailOptions, callback?: (error: Error, info: SentMessageInfo) => void): void;
+ close(): void;
+ }
+
+}
diff --git a/nodemailer/nodemailer.d.ts b/nodemailer/nodemailer.d.ts
index a63479e83..e0d1300b0 100644
--- a/nodemailer/nodemailer.d.ts
+++ b/nodemailer/nodemailer.d.ts
@@ -1,111 +1,63 @@
-// Type definitions for Nodemailer
-// Project: https://github.com/andris9/Nodemailer
-// Definitions by: Vincent Bortone
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-// Nodemailer is an easy to use module to send e-mails with Node.JS (using SMTP or sendmail or Amazon SES) and is unicode friendly .
-
-declare class Transport {
- static transports: {
- SMTP: Transport;
- SES: Transport;
- SENDMAIL: Transport;
- STUB: Transport;
- };
-
- constructor(type: string, options?: any);
- options: Object;
- transportType: string;
- sendMailWithTransport(emailMessage: MailComposer, callback?: (err: Error) => any): any;
- useDKIM(dkim: DKIMOptions): void;
- close(callback?: (err: Error) => any): any;
- sendMail(message: MailComposer, callback?: (err: Error) => any): any;
- send_mail(message:MailComposer, callback?: (err: Error) => any): any;
-}
-
-interface NodeMailerAttachment {
- fileName: string;
- filePath?: string;
- contents?: any;
- contentType?: string;
- cid?: string;
-}
-
-interface MailComposer {
- from: string; // sender info
- to: string; // Comma separated list of recipients
- subject: string; // Subject of the message
- headers?: {};
- text?: string; // plaintext body
- html?: string; // HTML body
- attachments?: NodeMailerAttachment[]; // An array of attachments
- forceEmbeddedImages?: boolean;
-}
-
-interface DKIMOptions{
- domainName: string; // signing domain
- keySelector: string; // selector name (in this case there's a dkim._domainkey.do-not-trust.node.ee TXT record set up)
- privateKey: any;
-}
-
-declare class XOAuthGenerator {
- constructor(options: XOAuthGeneratorOptions);
- generate(callback: () => any): string;
-}
-
-interface XOAuthGeneratorOptions {
- user: string;
- consumerKey: string; // optional
- consumerSecret: string; // optional
- token: string;
- tokenSecret: string;
-}
-
-interface XOAuth2Options {
- user: string;
- clientId: string;
- clientSecret: string;
- refreshToken: string;
-}
-
-interface NodemailerTransportOptions {
- service?: string;
- auth?: NodemailerAuthInterface;
- debug?: boolean;
- AWSAccessKeyID?: string;
- AWSSecretKey: string;
- ServiceUrl: string;
-}
-
-interface NodemailerAuthInterface {
- user?: string;
- pass?: string;
- XOAuthToken?: XOAuthGenerator;
- XOAuth2?: XOAuth2Options;
-}
-
-interface NodemailerSMTPTransportOptions {
- service?: string;
- host?: string;
- port?: number;
- secureConnection?: boolean;
- name?: string;
- auth: NodemailerAuthInterface;
- ignoreTLS?: boolean;
- debug?: boolean;
- maxConnections?: number;
-}
-
-
-interface Nodemailer {
- createTransport(type: string): Transport;
- createTransport(type: string, options: NodemailerTransportOptions): Transport;
- createTransport(type: string, options: NodemailerSMTPTransportOptions): Transport;
- createTransport(type: string, path: string): Transport;
- createXOAuthGenerator(options: XOAuthGeneratorOptions): XOAuthGenerator;
-}
-
-declare module "nodemailer" {
- var nodemailer: Nodemailer;
- export = nodemailer;
-}
+// Type definitions for Nodemailer 1.3.2
+// Project: https://github.com/andris9/Nodemailer
+// Definitions by: Rogier Schouten
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+///
+///
+///
+
+declare module "nodemailer" {
+
+ import directTransport = require("nodemailer-direct-transport");
+ import smtpTransport = require("nodemailer-smtp-transport");
+
+ export type Transport = nodemailer.Transport;
+ export type SendMailOptions = nodemailer.SendMailOptions;
+ export type SentMessageInfo = nodemailer.SentMessageInfo;
+
+ /**
+ * Transporter plugin
+ */
+ export interface Plugin {
+ (mail: SendMailOptions, callback?: (error: Error, info: SentMessageInfo) => void): void;
+ }
+
+ /**
+ * This is what you use to send mail
+ */
+ export interface Transporter {
+ /**
+ * Send a mail
+ */
+ sendMail(mail: SendMailOptions, callback?: (error: Error, info: SentMessageInfo) => void): void;
+
+ /**
+ * Attach a plugin. 'compile' and 'stream' plugins can be attached with use(plugin) method
+ *
+ * @param step is a string, either 'compile' or 'stream' thatd defines when the plugin should be hooked
+ * @param pluginFunc is a function that takes two arguments: the mail object and a callback function
+ */
+ use(step: string, plugin: Plugin): void;
+
+
+ /**
+ * Close all connections
+ */
+ close?(): void;
+ }
+
+ /**
+ * Create a direct transporter
+ */
+ export function createTransport(options?: directTransport.DirectOptions): Transporter;
+ /**
+ * Create an SMTP transporter
+ */
+ export function createTransport(options?: smtpTransport.SmtpOptions): Transporter;
+ /**
+ * Create a transporter from a given implementation
+ */
+ export function createTransport(transport: Transport): Transporter;
+}