Passbolt logo

Passbolt: How to Solve ‘Could not send the test email’ (SMTP Relay Gmail)

I have been playing with installing Passbolt recently. Everything went quite smoothly except Passbolt was unable to send any emails through Google / Gmail SMTP Relay.

Whether set to 465 or 587 ports, nothing would work with TLS enabled.

I would get errors such as:

[220] smtp-relay.gmail.com ESMTP i18-20020a4a6f52000000b004d1c7090475sm57294oof.16 - gsmtp
Could not send the test email.
Error: SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS.

The documentation was not helpful, running a healthcheck would show everything in order as well. After browsing Passbolt forums I have narrowed the issue to the client value not set (null). Unfortunately, this is hardly mentioned anywhere. If client value is null, most SMTP server will reject email messages to be sent. You need to set client to your server’s actual IP address and suddenly emails are sent!

Edit your config/passbolt.php and set your email values:

// Email configuration.
'EmailTransport' => [
 'default' => [
  'host' => 'smtp-relay.gmail.com',
  'port' => 587, 
  'username' => 'username', 
  'password' => 'password',
  // Is this a secure connection? true if yes, null if no.
  'tls' => true, 
  //'timeout' => 30,
  'client' => '127.0.0.1', // CHANGE this to your server's IP address!
  //'url' => null, 
 ], 
], 

You can then test email sending to be successful:

sudo su -s /bin/bash -c "/www/passbolt/bin/cake passbolt send_test_email --recipient=example@example.com --verbose" www-data

And the result:

-------------------------------------------------------------------------------
Email configuration
-------------------------------------------------------------------------------
Host: smtp-relay.gmail.com
Port: 587
Username: example@example.com
Password: *********
TLS: true
Sending email from: User <email@example.com>
Sending email to: example@example.com
-------------------------------------------------------------------------------
Trace
[220] smtp-relay.gmail.com ESMTP cn20-20020a0566383a1400b0038acbf4c0c6sm52381jab.60 - gsmtp
[250] 2.0.0 OK 1673001798 cn20-20020a0566383a1400b0038acbf4c0c6sm52381jab.60 - gsmtp
QUIT
The message has been successfully sent!

Easy solution, but difficult to find as it is not mentioned anywhere in the installation or configuration instructions!


Have a comment? Join discussion on Mastodon as a reply to: @dusoft@fosstodon.org