gulp edm测试

时间:2021-09-01 10:14:41

gulp工具的 gulp-mailgun 插件可以将你的html代码,通过mailgun服务器来发送,用于测试,用这个工具发送邮件最适合不过了。

首先我们需要引入gulp和gulp-mailgun模块:

var gulp = require("gulp"),
sendmail = require('gulp-mailgun');

然后写执行任务:

gulp.task('sendmail', function () {
gulp.src( '*/*.html') // 需要发送的edm文件的路径
.pipe(sendmail({
key: 'enter-your-api-key-here', // 输入你的 Mailgun API 密钥
sender: 'from@test.com', // 发送者的邮箱
recipient: 'to@test.com', // 接收者的邮箱
// recipient: 'bigpet1991@163.com, 286030975@qq.com, hpzeng@Ctrip.com, bigpet1991@gmail.com', // 多个邮件接收人
subject: 'This is a test email' // 邮件标题
}));
});

mailgun注册和设置