Skip to content

Commit cc4452b

Browse files
author
Marcus Baer
committed
Use with text messages
1 parent b513af6 commit cc4452b

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ lib-cov
1010
pids
1111
logs
1212
results
13+
node_modules
1314

1415
npm-debug.log

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ Options
5252
Any options can be set by both methods `options()` and `send()`. With `options()` you can define default configuration, e.g. from an extra local file, that is not in a repository. All options to `send()` will overwrite default.
5353

5454
The folder assets holds HTML mail template and attached files.
55+
56+
Use option `text` to set a message text instead of using a template.

index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ Emailer = (function() {
1717

1818
Emailer.prototype.send = function(callback) {
1919
var attachments, html, messageData, transport;
20-
html = this.getHtml(this.options.template, this.data);
20+
if (this.options.template) {
21+
html = this.getHtml(this.options.template, this.data);
22+
}
2123
attachments = this.getAttachments(html);
2224
messageData = {
2325
to: "'" + this.options.to.name + " " + this.options.to.surname + "' <" + this.options.to.email + ">",
2426
from: this.options.from,
2527
subject: this.options.subject,
26-
html: html,
27-
generateTextFromHTML: true,
2828
attachments: attachments
2929
};
30+
if (html) {
31+
messageData.html = html;
32+
messageData.generateTextFromHTML = true;
33+
} else {
34+
messageData.text = this.options.text;
35+
}
3036
transport = this.getTransport();
3137
return transport.sendMail(messageData, callback);
3238
};

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gmail-sender",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Sends emails by a given Gmail account",
55
"homepage": "http://github.com/marcusbaer/node-gmail-sender",
66
"keywords": [
@@ -29,11 +29,11 @@
2929
"npm": ">=1.2.14"
3030
},
3131
"dependencies": {
32-
"nodemailer": "~0.4.1",
32+
"nodemailer": "~0.5.15",
3333
"underscore": "~1.4.4"
3434
},
3535
"main": "./index.js",
3636
"readmeFilename": "README.md",
37-
"_id": "gmail-sender@0.1.0",
37+
"_id": "gmail-sender@0.1.1",
3838
"_from": "gmail-sender@"
3939
}

0 commit comments

Comments
 (0)