Skip to content

A gulp plugin to send emails with or without attachments from a stream of html.

License

Notifications You must be signed in to change notification settings

jansanchez/gulp-email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gulp Email NPM version Build Status

A gulp plugin to send emails with or without attachments from a stream of html.

Getting Started

Install:

npm install --save-dev gulp-email

How to use:

For example, using mailgun.com(registration it's free and you can send up to 10,000 emails every day.)

Sending an email like report HTML and attaching a file.

    var gulp = require('gulp'),
        email = require('gulp-email');
    
    var options = {
        user: 'api:key-564dfgfead753fghef11c54c1fb',
        url: 'https://api.mailgun.net/v2/sandbox4825.mailgun.org/messages',
        form: {
            from: 'John Doe <John.Doe@gmail.com>',
            to: 'Fulano Mengano <fulano.mengano@gmail.com>',
            subject: 'The last dist',
            attachment: '@path/to/folder/dist.zip'
        }
    };

    gulp.task('email', function () {
        return gulp.src(['./demo/reports/*.html'])
            .pipe(email(options));
    });

Sending an email without the content of a stream.

    var gulp = require('gulp'),
        email = require('gulp-email');
    
    var options = {
            user: 'api:key-564dfgfead753fghef11c54c1fb',
            url: 'https://api.mailgun.net/v2/sandbox4825.mailgun.org/messages',
            form: {
                from: 'John Doe <John.Doe@gmail.com>',
                to: 'Fulano Mengano <fulano.mengano@gmail.com>',
                cc: 'Regis Messac <regis.messac@gmail.com>',
                bcc: 'John Smith <john.smith@gmail.com>',
                subject: 'You have an new email',
                text: 'text version'
            },
            form_string: {
                html: '<p>Overwrite to html content of stream files.</p>'
            }
        };

    gulp.task('email', function () {
        return gulp.src(['./demo/no-matter.html'])
            .pipe(email(options));
    });

For these examples I am using the API of mailgun.com(I recommend). In this first release only supports mailgun API and is more than enough.

About

A gulp plugin to send emails with or without attachments from a stream of html.

Resources

License

Stars

Watchers

Forks

Packages

No packages published