Node Red emailer and 0auth2- "ReferenceError: msg is not defined" function check

I have setup an email node with Oauth2 authentication, that side of it is working, I have got the access token ok.

I am getting an error on deploy when from the email node itself. ("ReferenceError: msg is not defined") This is only when I enable the Oauth2 authentication in the email node. so perhaps there is an issue in my message it is not properly defined for the email node? Ive tried a couple/alot of different format options havent managed as yet. What am I missing?

// Extract necessary values from input msg
let access_token = msg.oauth2Response.access_token;

// Create a new message object with only the necessary properties
let newMsg = {
    payload: 'this is a dummy email',
    topic: 'some title',
    oauth2Response: {
        access_token: access_token
    }
};

// Return the new message object
return newMsg;

also tried this function to create the email.

// Add payload and topic properties to the msg object

msg.payload = 'this is a dummy email';

msg.topic = 'some title';

// Return the modified msg object

return msg;

@hadwll

I think this is a bug with the node - or at least its assumptions are incorrect.

@dceejay @Steve-Mcl

The node initializer is expecting an msg property - but during init, it will not exist?

C'tor

Trying to use msg in there

This would explain the error occurring during deploy?

IMO adjusting SMTP auth methods should be occurring on input ?
certainly if auth values are to be taken from msg

I might be a little rusty - so forgive me, if i'm just talking rubbish

1 Like

It certainly does look like a bug was introduced in XOAuth2 for Email-In node by wooferguy · Pull Request #975 · node-red/node-red-nodes · GitHub

@hadwll - could you please raise an issue and link back to this thread?

1 Like

yes, no problem, The issue is here node-red-node-email, send node "ReferenceError: msg is not defined" on deploy · Issue #1054 · node-red/node-red-nodes · GitHub

I wanted to ask then is this stopping my email sending?

As it is not working working for me and not presenting any error, I placed a catch node but it shows nothing as well.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.