How to send email from your Google Workplace hosted email account

So I was struggling like many on here, I couldn’t send email via smtp with my credentials via smtp.google.com.

The solution is to use Gmail’s SMTP relay service that you can configure via your admin panel for your Workplace hosted domain.

Login to your Admin panel:

  1. Go to [Apps > Google Workspace > Gmail > Routing]
  2. Next to SMTP relay service, click Configure.
  3. Set up the SMTP relay service by following the steps in [SMTP relay: Route outgoing non-Gmail messages through Google]

Then, in your env file, use the following:

MAIL_MAILER=smtp
MAIL_HOST=smtp-relay.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xxxx
MAIL_PASSWORD=xxxx
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=xxxx
MAIL_FROM_NAME=xxxx

Hope this helps somebody!

2 Likes

Hi,

Thanks for sharing the solution!

cc @david

Adding to the knowledge
If someone is getting

tail -f ilr_inv_nnj/storage/logs/invoiceninja.log
[2023-08-25 16:32:29] production.INFO: latest version = 5.7.3
[2023-08-25 16:32:44] production.INFO: Trying to send to *REDUCTED* 2023-08-25 16:32:44
[2023-08-25 16:32:44] production.INFO: Using mailer => smtp
[2023-08-25 16:32:45] production.INFO: Mailer failed with Failed to authenticate on SMTP server with username "*REDUCTED*" using the following authenticators: "LOGIN", "PLAIN", "XOAUTH2". Authenticator "LOGIN" returned "Expected response code "235" but got code "534", with message "534-5.7.9 Application-specific password required. Learn more at
534 5.7.9  https://support.google.com/mail/?p=InvalidSecondFactor p67-20020a257446000000b00d212ecd98f5sm102810ybc.21 - gsmtp".". Authenticator "PLAIN" returned "Expected response code "235" but got code "534", with message 

Set it up here - https://myaccount.google.com/apppasswords

1 Like

Using invoice ninja 5.8.35

I use one domain/hosting just for the invoicing, since I have multiple websites

My google workplace has all these domains attached to it, including the invoicing one, so all my email comes to one place.

I set up a smtp-relay.gmail . com settings. And invoice ninja will only throw a 403 error when I use the send test email.

Any ideas?

You may want to use an SMTP tester to ensure the credentials are correct.

Also of note. When configuring the SMTP relay settings in your google admin panel, if you limit by IP address make sure to add both IPv4 and IPv6. I’m on Linode and it was actually using the v6 address which I initially did not add.

2 Likes

Just found out that there is a new option in UI for SMTP settings. No documentation on it. Sadly.
Not sure what “Verify Peer” means.

Verify peer is an SMTP setting which enables “the process of matching names that are specified in the TLS profile against names that are defined in the peer’s certificate”.

Note: the from address is missing in the Flutter app but is available in the React app, it will be included with the next release of the Flutter app.