Reputation: 675
I was using the 'email' out node in node-red and sending emails, but suddenly it stopped working and giving me the following error:
Error: Mail command failed: 530-5.5.1 Authentication Required. Learn more at530 5.5.1 https://support.google.com/mail/?p=WantAuthError p19sm7126611pfj.140 - gsmtp
the 'function' node I was using have all the required variables msg.to
,msg.from
,msg.topic
.
Upvotes: 4
Views: 1300
Reputation: 6556
So I dug into the node-red-node-email module [https://www.npmjs.com/package/node-red-node-email] and look up the code, and found that:
...
var globalkeys = RED.settings.email || require(process.env.NODE_RED_HOME+"/../emailkeys.js");
...
var flag = false;
if (this.credentials && this.credentials.hasOwnProperty("userid")) {
this.userid = this.credentials.userid;
} else {
if (globalkeys) {
this.userid = globalkeys.user;
flag = true;
}
}
if (this.credentials && this.credentials.hasOwnProperty("password")) {
this.password = this.credentials.password;
} else {
if (globalkeys) {
this.password = globalkeys.pass;
flag = true;
}
}
if (flag) {
RED.nodes.addCredentials(n.id,{userid:this.userid, password:this.password, global:true});
}
https://github.com/node-red/node-red-nodes/blob/master/social/email/61-email.js#L25
So if we set the email credentials in RED.settings
(this file - https://github.com/node-red/node-red/blob/master/settings.js), it will use that email credentials to send the email properly:
email: {
user: '[email protected]',
pass: 'password'
}
and it will persist in all environments.
Upvotes: 2