Reputation: 1410
Hello I am using nodemailer to send an email. It works fine on local host but it doesn't work when I deploy it to the remote website.
I get the following error message when I try to send an email on the remote website:
ERROR === { Error: Invalid sender “<[email protected]>”
2016-08-15T05:05:01.034175+00:00 app[web.1]: at SMTPConnection._formatError (/app/node_modules/smtp-connection/lib/smtp-connection.js:493:15)
2016-08-15T05:05:01.034175+00:00 app[web.1]: at SMTPConnection._setEnvelope (/app/node_modules/smtp-connection/lib/smtp-connection.js:688:30)
2016-08-15T05:05:01.034176+00:00 app[web.1]: at SMTPConnection.send (/app/node_modules/smtp-connection/lib/smtp-connection.js:364:10)
2016-08-15T05:05:01.034177+00:00 app[web.1]: at SMTPTransport.<anonymous> (/app/node_modules/nodemailer-smtp-transport/lib/smtp-transport.js:126:24)
2016-08-15T05:05:01.034178+00:00 app[web.1]: at /app/node_modules/nodemailer-smtp-transport/lib/smtp-transport.js:162:21
2016-08-15T05:05:01.034178+00:00 app[web.1]: at SMTPConnection._actionAUTHComplete (/app/node_modules/smtp-connection/lib/smtp-connection.js:1185:5)
2016-08-15T05:05:01.034179+00:00 app[web.1]: at SMTPConnection.<anonymous> (/app/node_modules/smtp-connection/lib/smtp-connection.js:307:22)
2016-08-15T05:05:01.034180+00:00 app[web.1]: at SMTPConnection._processResponse (/app/node_modules/smtp-connection/lib/smtp-connection.js:634:16)
2016-08-15T05:05:01.034180+00:00 app[web.1]: at SMTPConnection._onData (/app/node_modules/smtp-connection/lib/smtp-connection.js:458:10)
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'Mailgun',
auth: {
user: process.env.MAILGUN_USERNAME,
pass: process.env.MAILGUN_PASSWORD
}
});
/**
*
*/
exports.contact = function(from, to) {
var mailOptions = {
from: from.name + ' ' + '<'+ from.email + '>',
to: to.email,
subject: from.subject || "No Subject",
text: from.message
};
transporter.sendMail(mailOptions, function(err) {
if (err){
console.log("ERROR === ", err);
}
});
};
I have already given access for my email address for less secure apps so that should not be the problem. Does anyone know why it would work on the local website but not the remote website?
Upvotes: 3
Views: 2493
Reputation: 761
Nodemailer does not support proxies and currently there is no plan to add any support for these, sorry.
Reference - Nodemailer Issue With Proxy
Upvotes: 1
Reputation: 1410
Alright it appears that adding the brackets seemed to prevent nodemailer from working on remote even though it worked locally.
I changed the code to the following:
var mailOptions = {
from: from.email
to: to.email,
subject: from.subject || "No Subject",
text: from.message
};
And it works now for sending emails on my remote server
Upvotes: 0