Files
anchann a66fe34169 Nodemailer: type definitions for the SMPT-specific options
As documented here:
https://github.com/andris9/nodemailer#setting-up-smtp

Added examples from the above source as tests.

The original definition of NodemailerTransportOptions looks questionable
with its AWS-specific fields, but leaving it alone for now since I'm
new to nodemailer.

Once typescript 0.9 is rolled out with its string parameter matcher,
that should be used for specifying the type of options of the second
parameter when the first one has value "SMTP".
2013-05-05 10:41:51 +09:00

106 lines
2.8 KiB
TypeScript

// Type definitions for Nodemailer
// 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 .
// Project: https://github.com/andris9/Nodemailer
// Definitions by: Vincent Bortone <https://github.com/vbortone/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
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);
close(callback?: (err: Error) => 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?: bool;
}
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;
}
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?: bool;
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?: bool;
name?: string;
auth: NodemailerAuthInterface;
ignoreTLS?: bool;
debug?: bool;
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;
}