This repository has been archived by the owner on Sep 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from happymedium/dev
Implement Nodemailer for test emails
- Loading branch information
Showing
8 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ module.exports = function(grunt) { | |
|
||
var path = require('path'); | ||
|
||
// Allow user to specify template to send through the CLI | ||
var template = grunt.option('template'); | ||
|
||
require('load-grunt-tasks')(grunt); | ||
|
||
grunt.initConfig({ | ||
|
@@ -74,6 +77,8 @@ module.exports = function(grunt) { | |
|
||
/** | ||
* Insert the media query css into the document manually. | ||
* | ||
* Remember: you'll need to update each style section as you add/remove templates. | ||
*/ | ||
htmlbuild: { | ||
dist: { | ||
|
@@ -82,7 +87,10 @@ module.exports = function(grunt) { | |
options: { | ||
relative: true, | ||
styles: { | ||
mq: '<%= paths.css %>/mq.css' | ||
basic: ['<%= paths.css%>/basic.css','<%= paths.css %>/mq.css'], | ||
hero: ['<%= paths.css%>/hero.css','<%= paths.css %>/mq.css'], | ||
sidebar: ['<%= paths.css%>/sidebar.css','<%= paths.css %>/mq.css'], | ||
sidebarHero: ['<%= paths.css%>/sidebar-hero.css','<%= paths.css %>/mq.css'] | ||
} | ||
} | ||
} | ||
|
@@ -105,6 +113,39 @@ module.exports = function(grunt) { | |
} | ||
}, | ||
|
||
// Send a test email to whomever we choose | ||
nodemailer: { | ||
|
||
options: { | ||
|
||
/** | ||
* Defaults to sendmail if you don't specify a transport below | ||
* See config/nodemailer-transport.json for a sample Gmail config, | ||
* or visit https://github.com/andris9/Nodemailer for all options | ||
*/ | ||
transport: grunt.file.readJSON('config/nodemailer-transport.json'), | ||
|
||
// By default, generate text from our HTML template automatically | ||
generateTextFromHTML: true, | ||
|
||
message: { | ||
from: 'From Name <[email protected]>', | ||
subject: 'Email template test' | ||
}, | ||
|
||
// A collection of recipients | ||
recipients: [{ | ||
email: '[email protected]', | ||
name: 'Recipient Name' | ||
}] | ||
}, | ||
|
||
// Load the HTML template from our dist directory. | ||
dist: { | ||
src: ['<%= paths.dist %>/' + template + '.html'] | ||
} | ||
}, | ||
|
||
/** | ||
* Inline the CSS from the external file into the document | ||
* This also copies the templates into the /dist/ folder | ||
|
@@ -180,6 +221,18 @@ module.exports = function(grunt) { | |
// To distribute, do the other two steps | ||
grunt.registerTask('dist', ['compass', 'clean', 'imagemin', 'render:dist', 'premailer', 'htmlbuild']); | ||
|
||
// Register a send tast to simulate an email delivery | ||
grunt.registerTask('send', 'Simulates an email delivery.', function() { | ||
if ( !template ) { | ||
grunt.fail.fatal('You need to specify a template to send: --template=templateName'); | ||
} | ||
|
||
grunt.task.run([ | ||
'dist', | ||
'nodemailer' | ||
]); | ||
}); | ||
|
||
// By default, do the dev version | ||
grunt.registerTask('default', ['dev']); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"type": "SMTP", | ||
"options": { | ||
"service": "Gmail", | ||
"auth": { | ||
"user": "GMAIL_USERNAME", | ||
"pass": "GMAIL_PASSWORD" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters