SocialGouv / domifa

Faciliter l'accès aux droits pour les personnes sans domicile stable, en simplifiant la gestion de la domiciliation
https://domifa.fabrique.social.gouv.fr
Apache License 2.0
14 stars 10 forks source link

🐞 Bug - Empty user and password for SMTP #3579

Open B-Prod opened 6 days ago

B-Prod commented 6 days ago

🖥️ Site(s) concerné(s)

🚫 Description du problème

When defining the SMTP credentials, we need to specify an empty user and password.

This leads to the following error, as the related variables DOMIFA_MAIL_SMTP_MAILTRAP_USER and DOMIFA_MAIL_SMTP_MAILTRAP_PASSWORD are set as required and does not allow empty strings:

[configParser] missing required env value "DOMIFA_MAIL_SMTP_MAILTRAP_USER"

However in local, we would like to use mailhog with the following settings:

      DOMIFA_MAIL_SMTP_MAILTRAP_HOST: mailhog
      DOMIFA_MAIL_SMTP_MAILTRAP_PORT: 1025
      DOMIFA_MAIL_SMTP_MAILTRAP_USER: ''
      DOMIFA_MAIL_SMTP_MAILTRAP_PASSWORD: ''

Moreover, the variable DOMIFA_TIPIMAIL_FROM_EMAIL is required, even if the chosen email provider is MAILTRAP.

Structure concernée (optionnel)

No response

🔮 Comportement attendu

Make the DOMIFA_TIPIMAIL_FROM_EMAIL environment variable required only if the mail provider is TIPIMAIL.

Allow empty string for user and password in mail configuration.

B-Prod commented 6 days ago

The patch below fixes the 2 issues:

domifa-email-configuration-3579.patch

pYassine commented 6 days ago

You can add change "DOMIFA_MAIL_SMTP_TIPIMAIL_HOST" by mailtrap. It will make tipimail variables as optionnal

B-Prod commented 6 days ago

Thank you.

So the MAILTRAP variables should not be used at all?

If I switch all environment variables to use TIPIMAIL instead of MAILTRAP, I don't have the issue. However, the MAILTRAP sender is the one defined in some .env example files, maybe it should be changed to TIPIMAIL.

The provided patch also fixes another issue with empty username and password. Even if using TIPIMAIL variables, empty user or password is not allowed:

missing required env value "DOMIFA_MAIL_SMTP_TIPIMAIL_USER"