Unable to login using email address based on custom domain Google Cloud host

I have been trying to set up a custom email domain and add email accounts based on it in a self hosted ERPNext instance. The ERPNext application is hosted on Google cloud platform. So far I have been able to add the custom domain but after adding a user and his corresponding email account when I try to login using that account into ERPNext I get “Invalid Login. Try again.” error. I have checked the access credentials are correct. The email accounts that we are using are G Suite accounts. Thus they are Gmail accounts but with custom domain. On clicking the Forgot password link I get the error “Not a valid user.”. While adding the domain I have added “imap.gmail.com” as the incoming server and checked on IMAP and SSL. I have also selected “smtp.gmail.com” for outgoing server with TLS checked and port selected as 587. What is going wrong? I desperately need help with this stubborn issue.

Looks like your email domain setup is correct.

If you want the email sending to work, gmail has security protection.

Gmail will only work if you allow access for less secure apps in Gmail settings. Less secure apps & your Google Account - Google Account Help

But if you only use the account to login to ERPNext, the setting above does not matter whether you set it or not. Maybe login using administrator and go to the gsuite user, then change the password to something default. Then try if you can login.

I had forgotten to mention that access to less secure apps had already been enabled. As suggested, I logged in as an Administrator and changed the password to something default that differs from my actual Gmail password. I immediately got “Authentication failed” error. The error was gone on entering the correct password. This proves that ERPNext is at least able to connect to Google’s mail server. But I am still getting the “Invalid Login. Try again.” error on trying to login using the email address and the correct password. I cannot figure out why is it not recognizing the user and giving “Not a valid user.” error on using the Forgot password link.

To troubleshoot and confirm your login settings are valid you could use another mail client such as Thunderbird

I applied the same login settings with Thunderbird. I can see my Inbox mails in it. But I am unable to make the same settings work for ERPNext.

In that case likely a stale cache, so clear and flush those.

You are self hosted so refer to ‘bench --help’.

Clearing the cache does not help either.

Try another browser and be sure to clear its cache too…

I did exactly the same. It does not work, I am afraid.

Next inspect the erpnext logs and /var/log for clues if you have not done that.

Where can I see the ERPNext logs? Can you provide the path to access it on the server?

Try for example this
frappe@erpnext:~/frappe-bench$ find . -name *.log | xargs grep frappe.email.queue.flush

1 Like

“I cannot figure out why is it not recognizing the user and giving “Not a valid user.” error on using the Forgot password link.”

Some ideas

  1. ‘hard’ evidence screenshots or log entries would help clarify your problem context. I am not exactly clear here myself…

  2. This may have to do with your problem
    Control access to less secure apps - Google Workspace Admin Help

  3. As Administrator, delete the ‘invalid user’ then recreate that same User

Hi Clarkej,

My issue is now resolved. What really worked for me was

But before that I had to create a default email account for incoming and outgoing emails. I received a welcome email from that default email account with a link to reset the password on recreating the user. I clicked on the link, reset the password and voila thereafter I was able to login successfully. I did not know that the solution was so simple.

Thanks a ton!

Best regards,
Rupam Kundu

1 Like