Socket
Socket
Sign inDemoInstall

nodemailer

Package Overview
Dependencies
Maintainers
1
Versions
271
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodemailer - npm Package Compare versions

Comparing version 0.3.5 to 0.3.6

5

examples/example_sendmail.js

@@ -11,5 +11,2 @@ var nodemailer = require('../lib/nodemailer');

// define transport to deliver this message
transport: transport,
// sender info

@@ -62,3 +59,3 @@ from: 'Sender Name <sender@example.com>',

nodemailer.send_mail(message, function(error){
transport.send_mail(message, function(error){
if(error){

@@ -65,0 +62,0 @@ console.log('Error occured');

@@ -15,5 +15,2 @@ var nodemailer = require('../lib/nodemailer');

// define transport to deliver this message
transport: transport,
// sender info

@@ -66,3 +63,3 @@ from: 'Sender Name <sender@example.com>',

nodemailer.send_mail(message, function(error){
transport.send_mail(message, function(error){
if(error){

@@ -69,0 +66,0 @@ console.log('Error occured');

7

examples/example_smtp.js

@@ -15,7 +15,4 @@ var nodemailer = require('../lib/nodemailer');

// Message object
var message = {
var message = {
// define transport to deliver this message
transport: transport,
// sender info

@@ -71,3 +68,3 @@ from: 'Sender Name <sender@example.com>',

console.log('Sending Mail');
nodemailer.sendMail(message, function(error){
transport.sendMail(message, function(error){
if(error){

@@ -74,0 +71,0 @@ console.log('Error occured');

@@ -32,3 +32,6 @@ var spawn = require('child_process').spawn;

sendmail.on('exit', function (code) {
callback(code?new Error("Sendmail exited with "+code):null, {});
var msg = "Sendmail exited with "+code;
if(typeof callback == "function"){
callback(code?new Error(msg):null, {message: msg});
}
});

@@ -35,0 +38,0 @@

@@ -55,3 +55,3 @@ /*

if(err){
return callback(err);
return typeof callback == "function" && callback(err);
}

@@ -124,9 +124,9 @@ this.handleMessage(email, callback);

if(err instanceof Error) {
return callback && callback(err, null);
return typeof callback == "function" && callback(err, null);
}
if(response.statusCode != 200) {
return callback &&
return typeof callback == "function" &&
callback(new Error('Email failed: ' + response.statusCode + '\n' + body), null);
}
return callback && callback(null, {
return typeof callback == "function" && callback(null, {
message: body

@@ -133,0 +133,0 @@ });

@@ -94,3 +94,4 @@ var wellKnownHosts = require("../wellknown"),

(!this.options.auth || !this.options.auth.user || !this.options.auth.pass)){
return callback(new Error("Authentication required, invalid details provided"));
return typeof callback == "function" &&
callback(new Error("Authentication required, invalid details provided"));
}

@@ -97,0 +98,0 @@

var Transport = require("./transport").Transport,
createTransport = require("./transport").createTransport,
MailComposer = require("mailcomposer").MailComposer,

@@ -12,5 +11,12 @@ helpers = require("./helpers");

// Export createTransport method
module.exports.createTransport = createTransport;
module.exports.createTransport = function(type, options){
var transport = new Transport(type, options);
transport.sendMail = function(options, callback){
options = options || {};
options.transport = options.transport || transport;
sendMail(options, callback);
}
return transport;
};

@@ -24,3 +30,5 @@ // Export Transport constructor

// Export sendMail function (and the alias send_mail for legacy)
module.exports.sendMail = module.exports.send_mail = function(options, callback){
module.exports.sendMail = module.exports.send_mail = sendMail;
function sendMail(options, callback){
var mailer = new Nodemailer(options);

@@ -71,19 +79,19 @@

if(!this.options.SMTP._smtp_transport){
this.options.SMTP._smtp_transport = createTransport("SMTP", this.options.SMTP);
this.options.SMTP._smtp_transport = new Transport("SMTP", this.options.SMTP);
}
return this.options.SMTP._smtp_transport;
}else if(this.options.sendmail){
return createTransport("sendmail", this.options.sendmail);
return new Transport("sendmail", this.options.sendmail);
}else if(this.options.SES){
return createTransport("SES", this.options.SES);
return new Transport("SES", this.options.SES);
}else if(module.exports.SMTP){
// cache the transport for SMTP as it is actually a connection pool
if(!module.exports._smtp_transport){
module.exports._smtp_transport = createTransport("SMTP", module.exports.SMTP);
module.exports._smtp_transport = new Transport("SMTP", module.exports.SMTP);
}
return module.exports._smtp_transport;
}else if(module.exports.sendmail){
return createTransport("sendmail", module.exports.sendmail);
return new Transport("sendmail", module.exports.sendmail);
}else if(module.exports.SES){
return createTransport("SES", module.exports.SES);
return new Transport("SES", module.exports.SES);
}

@@ -117,3 +125,3 @@ return false;

// send the message using preselected transport method
this.transport.sendMail(this.mailcomposer, callback);
this.transport.sendMailWithTransport(this.mailcomposer, callback);
};

@@ -120,0 +128,0 @@

@@ -7,6 +7,2 @@ var SendmailTransport = require("./engines/sendmail"),

// Expose to the world
module.exports.createTransport = function(type, options){
return new Transport(type, options); // this way the "new" is optional
};
module.exports.Transport = Transport;

@@ -50,3 +46,3 @@

*/
Transport.prototype.sendMail = function(emailMessage, callback){
Transport.prototype.sendMailWithTransport = function(emailMessage, callback){
if(!this.transport){

@@ -53,0 +49,0 @@ return callback(new Error("Invalid transport method defined"));

{
"name": "nodemailer",
"description": "Easy to use module to send e-mails, supports unicode and SSL/TLS",
"version": "0.3.5",
"version": "0.3.6",
"author" : "Andris Reinman",

@@ -6,0 +6,0 @@ "maintainers":[

@@ -5,7 +5,7 @@ Nodemailer

**Nodemailer** is an easy to use module to send e-mails with Node.JS (using
SMTP or sendmail) and is unicode friendly - You can use any characters you like ✔
SMTP or sendmail or Amazon SES) and is unicode friendly - You can use any characters you like ✔
Nodemailer is Windows friendly, you can install it with *npm* on Windows just like any other module, there are no compiled dependencies. Use it from Azure or from your Windows box hassle free.
This version of Nodemailer is built from scratch and might break some existing scripts, so beware while upgrading.
Version v0.3 of Nodemailer is built from scratch and might break some existing scripts, so beware while upgrading. Nodemailer should be backwards compatible - if your script worked before, then it should work now, even if Nodemailer documentation differs from your code (method names, properties etc.).

@@ -29,2 +29,3 @@ [Autogenerated docs](http://www.node.ee/maildoc/)

* **Preconfigured** services for using SMTP with Gmail, Hotmail etc.
* Use objects as header values for **SendGrid** SMTP API

@@ -48,3 +49,4 @@ ## Check out my other mail related modules

var transport = nodemailer.createTransport("SMTP",{
// create transport method
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",

@@ -58,3 +60,2 @@ auth: {

var mailOptions = {
transport: transport, // transport method to use
from: "Sender Name <sender@example.com>", // sender address

@@ -67,3 +68,4 @@ to: "receiver1@example.com, receiver2@example.com", // list of receivers

nodemailer.sendMail(mailOptions, function(error){
// send mail with defined transport object
smtpTransport.sendMail(mailOptions, function(error){
if(error){

@@ -92,5 +94,5 @@ console.log(error);

An e-mail can be sent with `sendMail(mailOptions, callback)` command
An e-mail can be sent with `sendMail(mailOptions[, callback])` command
nodemailer.sendMail(mailOptions, callback);
transport.sendMail(mailOptions, callback);

@@ -118,3 +120,2 @@ Where

var mailOptions = {
transport: transport,
from: "sender@tr.ee",

@@ -213,3 +214,3 @@ to: "receiver@tr.ee"

If you want to use a well known service as the SMTP host, you do not need
to enter the hostname or port number, just use the `service` parameter.
to enter the hostname or port number, just use the `service` parameter (**nb** case sensitive).

@@ -256,3 +257,2 @@ Currently cupported services are:

var mailOptions = {
transport: transport,
from: "me@tr.ee",

@@ -264,3 +264,3 @@ to: "me@tr.ee",

nodemailer.sendMail(mailOptions, function(){});
transport.sendMail(mailOptions);

@@ -267,0 +267,0 @@ ### SendGrid support

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc