How to configure SMTP with gmail?

I am currently setting up a server (self hosting). I want him to be able to send emails throught a gmail account. I haven’t seen any explanations about it anywhere in documentation or on the internet.
I’ve already set NO_EMAILS=FALSE, and SMTP_PORT=465 but informations are missing.
There is no exemple field to fill for user email and user password (like STMP_USER and STMP_PASSWORD).
What should I put in the configuration file ?

Thank you!

I finally was able to send emails from the Web App with the gmail SMTP! :tada:

First, I had to understand that set NO_EMAILS=FALSE will not disable the NO_EMAILS option! You need to comment/delete the line to enable mailing.

Next, I discovered the use of some environment variables that aren’t mentioned in file example.env:

  • SMTP_PASSWORD=YourGmailPassword

Finaly, I have this variables in the .env file:

  • SMTP_PASSWORD=YourGmailPassword
  • SMTP_PORT=587

You also need to allow SMTP on your Gmail account.

Thanks to this stackoverflow, I understood that the development mode isn’t setup to use these variables, you have to be in production mode. Actually in v9.0.2, in development mode the port is hard-coded to 1025 (why ?) and doesn’t use SMTP_USERNAME and SMTP_PORT, so it can’t send emails.


@Pitou I’m glad you were able to figure it out and thank you for sharing your your solution. I’m sure it will help many other developers.

@Pitou - I’ve been trying to get SMTP working with a local SMTP server as well as my Gmail account and have had no luck. Did you have to do anything except update the .env file as you mentioned above?

You need to allow less secure apps to send email from your Google account :
That what I meant by:

You also need to allow SMTP on your Gmail account.

Then, you need to have the farmbot application in production mode (otherwise the port for smtp is hardcoded to 1025)
Edit the .env as I mentioned above.

That all I did :slight_smile:

1 Like

@Pitou this is weird. I’ve done all of this but I still don’t have it working. I also can’t get it to work with a mail server that’s local to the Farmbot server itself so I must be missing something. I don’t see the Farmbot server hitting the mail server at all in the logs.

@Pitou - I guess I need more sleep! I got it working. I had a typo in my Gmail email address. I don’t use Gmail and my Gmail username is very close to a username I use all the time so I forgot 1 letter! :wink:

All good now!