Docker Setup Not Sending Email

Everything in my passbolt docker container seems to be running fine besides sending email through google smtp. I’ll be posting my ./bin/cake tests below, but first off can anyone validate my variables in my docker run? BTW I’m utilizing nginx-proxy and nginx-letsencrypt-companion for auto https and reverse proxy.

docker run --detach \
    --name passbolt \
    --restart always \
    --env TZ=America/Denver \
    --env APP_FULL_BASE_URL=https://password.example.com \
    --env PASSBOLT_SSL_FORCE=false \
    --env EMAIL_TRANSPORT_DEFAULT_CLASS_NAME=Smtp \
    --env EMAIL_DEFAULT_FROM=noreply@example.com \
    --env EMAIL_DEFAULT_TRANSPORT=Smtp \
    --env EMAIL_TRANSPORT_DEFAULT_HOST=smtp.gmail.com \
    --env EMAIL_TRANSPORT_DEFAULT_PORT=587 \
    --env EMAIL_TRANSPORT_DEFAULT_TLS=true \
    --env EMAIL_TRANSPORT_DEFUALT_USERNAME=noreply@example.com \
    --env EMAIL_TRANSPORT_DEFAULT_PASSWORD=password \
    --env PASSBOLT_KEY_EMAIL=admin@example.com \
    --env DATASOURCES_DEFAULT_HOST=passboltdb \
    --env DATASOURCES_DEFAULT_PASSWORD=password \
    --env DATASOURCES_DEFAULT_USERNAME=mypassbolt \
    --env DATASOURCES_DEFAULT_DATABASE=mypassbolt \
    passbolt:local

Running su -s /bin/bash -c "./bin/cake passbolt healthcheck" www-data from withing the container generates the following non “PASS” entries:

[WARN] The passbolt config file is missing in /var/www/passbolt/config/
 [HELP] Copy /var/www/passbolt/config/passbolt.php.default to /var/www/passbolt/config/passbolt.php
 [HELP] The passbolt config file is not required if passbolt is configured with environment variables

# to be expected since I'm using reverse proxy to handle SSL
[FAIL] Passbot is not configured to force SSL use.
 [HELP] Set passbolt.ssl.force to true in config/passbolt.php.

Running ./bin/cake EmailQueue.preview results in:

Email :
Exception: Transport config "Smtp" is missing. in [/var/www/passbolt/vendor/cakephp/cakephp/src/Mailer/Email.php, line 1582]

Line 1582 regarding the error above:

throw new InvalidArgumentException(sprintf('Transport config "%s" iss missing.', $name));

cat /var/log/cron.log

Exception: Transport config "Smtp" is missing. in [/var/www/passbolt/vendor cakephp/cakephp/src/Mailer/Email.php, line 1582]

./bin/cake passbolt send_test_email

Email configuration
---------------------------------------------------------------
Host: smtp.gmail.com
Port: 587
Username: 
Password: *********
TLS: true

Sending email from: noreply@example.com
Sending email to: doesnotexist@passboltdummydomain.com
---------------------------------------------------------------
Exception: Transport config "Smtp" is missing. in [/var/www/passbolt/vendor/cakephp/cakephp/src/Mailer/Email.php, line 1582]

Results with telnet smtp.gmail.com 587:

root@da86fcfe8844:/var/www/passbolt# telnet smtp.gmail.com 587
Trying 173.194.203.109...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 smtp.gmail.com ESMTP 204sm9750747pgf.61 - gsmtp
quit
221 2.0.0 closing connection 204sm9750747pgf.61 - gsmtp
Connection closed by foreign host.

Anyone have an idea here? I hate to reply to my own thread, but if anyone could at least validate my run command looks fine that would be something. Thanks.

Hello @rhett sorry that nobody answered I will try to reproduce your issue and come back at you with more details!

I think that is the problem. That env variable should be either not declared or declared with value ‘default’ as it points to the app.php EMAIL_TRANSPORT profile which is by default called ‘default’ (Unless you are defining a different EMAIL_TRANSPORT profile in app.php. In that case, you should declare the variable with the appropriate name of the profile you defined)

Also the following variable does not need to be declared since the default value is already ‘Smtp’ (it doesnt hurt to declare it as you did though):

Hope this helps to solve your problem!

Bonus points: Regarding the failures you mention on the healthcheck we are already working on a fix for them :slight_smile:

1 Like

Thanks, diego. I appreciate your help.

It appears I’m going in the right direction. However, I’m receiving the following error which seems password related, but I’ve verified my password, allowed less secure apps, and I’m using the same email in other docker containers for smtp.

Here’s what I’m getting:

 Debug email shell
---------------------------------------------------------------

Email configuration
---------------------------------------------------------------
Host: smtp.gmail.com
Port: 587
Username:
Password: *********
TLS: true

Sending email from: noreply@example.com
Sending email to: doesnotexist@passboltdummydomain.com
---------------------------------------------------------------

Trace
[220] smtp.gmail.com ESMTP l5-v6sm5678156qtp.91 - gsmtp
> EHLO localhost
[250] smtp.gmail.com at your service, [this.is.an.ip.address]
[250] SIZE 35882577
[250] 8BITMIME
[250] STARTTLS
[250] ENHANCEDSTATUSCODES
[250] PIPELINING
[250] CHUNKING
[250] SMTPUTF8
> STARTTLS
[220] 2.0.0 Ready to start TLS
> EHLO localhost
[250] smtp.gmail.com at your service, [this.is.an.ip.address]
[250] SIZE 35882577
[250] 8BITMIME
[250] AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
[250] ENHANCEDSTATUSCODES
[250] PIPELINING
[250] CHUNKING
[250] SMTPUTF8

A test email could not be sent.
Error: SMTP Error: 530 5.5.1  https://support.google.com/mail/?p=WantAuthError l5-v6sm5678156qtp.91 - gsmtp

I’ve triple-checked the user name and password. I’ll continue to investigate.

When running ./bin/cake passbolt send_test_email is it supposed to show something aside “Username:”? As you can see in my output above it’s blank.

cat /var/log/cron.log shows the following:

SMTP Error: 530 5.5.1  https://support.google.com/mail/?p=WantAuthError r68sm31799361pfi.174 - gsmtp
Email 1 was not sent
Notice Error: Trying to get property 'url' of non-object in [/var/www/passbolt/src/Template/Email/html/AN/user_register_self.ctp, line 22]

2018-04-26 00:13:01 Notice: Notice (8): Trying to get property 'url' of non-object in [/var/www/passbolt/src/Template/Email/html/AN/user_register_self.ctp, line 22]

Here’s the user_register_self.ctp line 22:

echo $this->element('Email/module/avatar',[
    'url' => Router::url(DS . $user->profile->avatar->url['small'], true),     ### LINE 22
    'text' => $this->element('Email/module/avatar_text', [
        'username' => Purifier::clean($user->username),
        'first_name' => Purifier::clean($user->profile->first_name),
        'last_name' => Purifier::clean($user->profile->last_name),
        'datetime' => $user->created,
        'text' => __('You have just created your account on passbolt!')
    ])
]);

Any have ideas?

@rhett this is from my working config;

@mannp, thanks.

If I run grep -rnw '/var/www/passbolt' -e 'smtp.gmail.com', I get no results, so I think if you use docker run and assign variables it doesn’t show in the configuration files.

Does ./bin/cake passbolt send_test_email show an actual user name for you? Sorry for all the questions. I’m wondering if I’d have less hassle using docker compose, or if I missed something simple.

@rhett my understanding is that the docker env variables don’t get added to passbolt.php, but instead they are parsed in default.php and are actioned by the code accordingly.

I was confused about this previously, but if you look at the code in default.php you can see the env variables are used in that file.

I have a combination of both but do have my email configured purely in passbolt.php.

That command shows the full messages between passbolt and gmail and ends in a sucessful send.

I’m getting the exact errors when using docker-compose. I know my sign in credentials are correct. The email I’m using does not have 2 factor authorization on. I’ve allowed less secure apps and the captcha unlock didn’t help either: https://accounts.google.com/b/0/DisplayUnlockCaptcha

Can anyone tell me what the EMAIL_TRANSPORT_DEFAULT_URL environment variable is? I have a notice as shown above complaining about an URL.

Thanks,

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