dwightjack / grunt-nodemailer Goto Github PK
View Code? Open in Web Editor NEWGrunt wrapper for Nodemailer
License: MIT License
Grunt wrapper for Nodemailer
License: MIT License
I am getting the error mail.message.getAddresses is not a function
.
I tried upgrading nodemailer to 2.3.0
, but I received the error Error occured: Missing email body
. I tried using 0.1.0
for the nodemailer-sendgrid-transport
, and it still has the same issue.
Any ideas?
Hey there,
Despite all the hair I've pulled outta my head over the last few hours, I love nodemailer :) I'm trying to send an image attachment and it's coming through, but with no data. 0kb in size. That's using this code:
var path = require('path');
var uploadDir = path.dirname(require.main.filename);
// This actually produces a filepath that starts at my /Applications dir on my Mac, but ends in the right spot.
var img = require("fs").readFileSync(uploadDir + '/uploads/' + params.newFileName);
// file was upload was handled on the server by multer and renamed to something like this: fc5c5921bd0892f114cd7b6f0d39d9a3.gif
attachments: [{
filename: params.newFileName,
filePath: img
}]
The image is in the directory, and there are no explicit errors. When I replace filePath above with path (as it's written in some places), I get an attachment called attachment-1.bin. I've also tried setting my img var as a value of the content property in the attachments object, to no avail. In fact I've probably tried about a hundred variations on the theme with no luck.
Update nodemailer to work with newer version. Will fix issue https://github.com/andris9/Nodemailer/issues/296 and #4
After I`d updated to version 1.0.0.0
I got next error each time
Fatal error: Error occured: connect ECONNREFUSED 127.0.0.1:25
I revert to 0.3.0, the problem was fixed.
Is there any global problem or I should change something in my settings or properties
When running
grunt -v acceptance-nightly
with the following excerpt from the gruntfile.js:
grunt.loadNpmTasks('grunt-nodemailer');
grunt.initConfig({
nodemailer: {
// Task-specific options go here.
options: {
trasport: {
options: {
host: 'outlook.corp.local'
}
},
message: {
subject: 'subject',
text: 'text'
},
recipients: [
{
email: '[email protected]',
name: 'John Doe'
}
]
}
}
});
grunt.registerTask('acceptance-nightly',['nodemailer']);
I received the following success message in the console:
Done, without errors.
whereas I expected to see the following printed to the console in addition to an error if the email task failed:
'Sending %d e-mail%s to recipients: %s'
I just can't have an attachment send via grunt node-mailer task.
My code looks like:
message: {
subject: 'A test e-mail',
text: 'Plain text message',
html: '
attachments : [
{ // file on disk as an attachment
filename: 'samtest.txt',
path: 'samtest.txt' // stream this file
},
],
alternatives : [
{ // file on disk as an attachment
filename: 'samtest.txt',
path: 'samtest.txt' // stream this file
},
],
},
I see no errors when I run the nodemailer task. I even receive the email, but without any attachment. What am I missing?
This is how my transport property looks like:
transport: {
type: 'SMTP',
options: {
service: 'Gmail',
auth: {
user: 's*******@gmail.com',
pass: ''"
}
}
}
Has anyone been able to get this repo working with Office365? I can't find any working examples and have only been able to get it to work with gMail but we use office for work so trying to find a way to get this working.
Appreciate any insight you can provide!
I want to inline the email HTML and send it to myself.
The inliner works fine, but I keep getting spawn ENOENT
error whenever I want to send the email.
My node is on v0.12.7
and I'm using Windows 10.
Here's what shown in CLI:
Running "nodemailer:send" (nodemailer) task
Sending 1 e-mail to recipients: "Me" <[email protected]>
Fatal error: Error occured: spawn sendmail ENOENT
Here's my Gruntfile:
"use strict";
module.exports = function(grunt) {
grunt.initConfig({
...
nodemailer: {
send: {
src: ["index.html"]
},
options: {
transport: {
type: "sendmail"
},
message: {
subject: "Test email",
from: "<Test> [email protected]"
},
recipients: [{
email: "[email protected]",
name: "Me"
}]
},
}, //end nodemailer
...
} //end initConfig
grunt.loadNpmTasks("grunt-nodemailer");
grunt.registerTask("send", function() { // the command is `grunt send`
grunt.task.run([
"juice:inliner", // I use juice to inline css, it works fine
"nodemailer:send"
]);
});
} //end module.exports
Can't I send email from localhost? Or is there a mistake in my configuration? I tried using Gmail just like the example and works fine.
Thanks
Note: I posted this issue on Stackoverflow. So far, there's no reply.
When I try send mail from 'sendmail transport' in terminal I see this:
Running "nodemailer:task" (nodemailer) task
Sending 1 e-mail to recipients: [email protected]
Fatal error: Error occured: spawn ENOENT
When I use filestub transport, my message sended
Windows 7 x64
node 0.10.30
None values from below does not work except first
...
attachments: [{
//filePath: 'build/output/ads.dev.master-61.ajs'
//filePath: grunt.config('vars.mail.attachment')
//filePath: grunt.file.expand('<%= vars.dest %>/*')[0]
//filePath: grunt.file.expand(grunt.config('vars.dest') + '/*')[0]
}]
...
Any idea how to make this does its job?
Can you set a subject in the message option if you're using a html file for the src?
When error occur, you see line like this:
Fatal error: Error occured: Error
If you change error.name
to error.message
in line:
grunt.fail.fatal('Error occured: ' + error.name);
you will see the error itself instead of just 'Error'.
After changing this you can see for example:
Fatal error: Error occured: Authentication required, invalid details provided
This is my current config:
nodemailer: {
options: {
transport: {
type: 'SMTP',
service: 'Gmail',
auth: {
user: 'my_gmail_user',
pass: 'my_password'
}
},
recipients: [
{
name: 'Test User',
email: '[email protected]'
}
]
},
dist: {
src: ['dist/index.html']
}
}
However running grunt nodemailer
throws the following error:
Running "nodemailer:dist" (nodemailer) task
Sending 1 e-mail to recipients: "Test User" <[email protected]>
Fatal error: Error occured: Error
It used to work fine when I used your custom send task, I read the docs but I couldn't find anything wrong maybe it's related to the "message" option? It should still be able to send with the "src" option correct?
Maybe, we could use a fake Gmail account in the demo configuration, so that every user does not need to go through all option and figure out the right one.
Thanks,
Ricky
I had missed this line in the documentation:
Accepted file extensions are .html, .htm and .txt.
and was trying to use a .json file as the body of my email.
The failure I was getting was:
Fatal error: Error occured: Can't send mail - no recipients defined
because the message was false
.
One option would be to improve the if/else if clause to better handle different file types (or at least log the file types are invalid).
Another option would be to add a test condition to async.eachSeries(messages, function (msg, next) {
if (!msg) {
grunt.fail.fatal('No message to send.');
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.