Initial commit of Nodemailer type definitions and tests

This commit is contained in:
Vincent Bortone
2013-01-31 02:59:19 -05:00
parent 7a764f1e24
commit 71fb1d4a12
2 changed files with 75 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
//Nodemailer test
/// <reference path="nodemailer.d.ts" />
var nodemailer:NodemailerStatic;
// create reusable transport method (opens pool of SMTP connections)
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "gmail.user@gmail.com",
pass: "userpass"
}
});
// setup e-mail data with unicode symbols
var mailOptions = {
from: "Fred Foo ✔ <foo@blurdybloop.com>", // sender address
to: "bar@blurdybloop.com, baz@blurdybloop.com", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world ✔", // plaintext body
html: "<b>Hello world ✔</b>" // html body
}
// send mail with defined transport object
smtpTransport.sendMail(mailOptions, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
// if you don't want to use this transport object anymore, uncomment following line
//smtpTransport.close(); // shut down the connection pool, no more messages
});
+42
View File
@@ -0,0 +1,42 @@
// Type definitions for Nodemailer
// JNodemailer 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
interface Transport {}
interface MailComposer {}
interface XOAuthGenerator {}
interface NodemailerTransportOptions {
service: string;
}
interface NodeMailerMessageOptions {}
interface NodemailerStatic {
X_MAILER_NAME: string;
X_MAILER_HOMEPAGE: string;
createTransport(type: string, options: NodeMailerTransportOptions): Transport;
sendMail(options: NodeMailerMessageOptions, callback?: (err: Error) => any): any;
send_mail(options: NodeMailerMessageOptions, callback?: (err: Error) => any): any;
}
interface Nodemailer {
(options: NodeMailerMessageOptions): void;
transport: Transport;
options: NodeMailerMessageOptions;
mailcomposer: MailComposer;
generateUserAgentString(): string;
getGlobalTransport(): Transport;
validateSettings(callback: (err: Error) => any): void;
sendMail(callback: () => any): void;
generateMailObject(): void;
setGeneralOptions(): void;
setUserHeaders(): void;
setModuleHeaders(): void;
setAttachments(): void;
}