Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add authentication to smtp relay host #204

Merged
merged 9 commits into from
Sep 14, 2024
Merged

Add authentication to smtp relay host #204

merged 9 commits into from
Sep 14, 2024

Conversation

Bonno
Copy link
Contributor

@Bonno Bonno commented Aug 17, 2022

I've added configuration to provide TLS SMTP authentication for relayhosts. This is necessary when using gmail as relayhost for your mailserver for example.
To make use of the TLS authentication you need to follow these steps:

  1. Create a config file './config/mta/sasl_passwd' with the following contents:
    [smtp.gmail.com]:587 username:password

  2. Add the following volume to 'docker-compose.override.yml' for the 'mta' service:
    ./config/mta/sasl_passwd:/etc/postfix/sasl_passwd

  3. Add the following lines to your '.env' file

RELAYHOST=[smtp.gmail.com]:587
RELAY_PASSWD_FILE=/etc/postfix/sasl_passwd
RELAY_OPTIONS=

@jeboehm
Copy link
Owner

jeboehm commented Aug 23, 2022

Hi @Bonno
thank you very much for your contribution!
What I'm missing is test coverage to see the authentication working. Could you add a case for that please?

@jeboehm jeboehm self-assigned this Aug 23, 2022
@jeboehm jeboehm removed their assignment Aug 23, 2022
@jeboehm jeboehm self-requested a review August 23, 2022 16:25
@Bonno
Copy link
Contributor Author

Bonno commented Mar 17, 2023

I'm not sure how to create tests for an authentication flow.

@tiberios1
Copy link

@Bonno @jeboehm is this now abandoned? I'm hoping not as it's something I now need. I'd like to help, but I have no idea how to write the test, although I'm willing to try to learn if someone can point me in the right direction.

@jeboehm
Copy link
Owner

jeboehm commented Sep 10, 2024

Hi @tiberios1
no, not abandoned. But the usual lack of time... :)
I'm sorry!

@tiberios1
Copy link

Totally understand the lack of time issue. Any chance you can give me some detail as to what needs doing and I'll see if I can help out?

@jeboehm
Copy link
Owner

jeboehm commented Sep 11, 2024

Hi @tiberios1
Thanks for your understanding!
The relay host scenario is tested here: https://github.com/jeboehm/docker-mailserver/blob/main/test/rootfs/usr/share/tests/080_relayhost.bats

https://github.com/jeboehm/docker-mailserver/blob/main/.github/workflows/integration-tests.yml describes, how tests are executed. In your case:

  • make .env
  • cat .ci/matrix/relayhost.env >> .env
  • make build
  • make test

An instance of mailhog is started (defined in https://github.com/jeboehm/docker-mailserver/blob/main/docker-compose.test.yml) and used to fake an external relay host. Problem here: mailhog doesn't support SMTP authentication.

I think mailpit is a good alternative for mailhog, as it supports smtp auth.

I hope this helps!

Bonno and others added 7 commits September 12, 2024 07:20
* origin/smtp-auth: (53 commits)
  smtp_use_tls is deprecated. New config is smtp_tls_security_level
  Change test to match mailpit api
  Add workflow_dispatch trigger to integration test
  Started working on test flow
  Add authentication to smtp relay host
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.23
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.22
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.21
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.20
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.19
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.18
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.17
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.16
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.15
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.14
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.13
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.12
  chore(deps): update actions/checkout action to v4 (main) (jeboehm#308)
  chore(deps): update dependency jeboehm/mailserver-admin to v2.1.11
  fix: prevent admin from deleting migrations table (jeboehm#307)
  ...
@Bonno
Copy link
Contributor Author

Bonno commented Sep 13, 2024

Thanks to the breakdown from @jeboehm I was able to change a few bits and now we have a successful test scenario for this PR.

@jeboehm jeboehm merged commit f7caed5 into jeboehm:main Sep 14, 2024
6 checks passed
@jeboehm
Copy link
Owner

jeboehm commented Sep 14, 2024

Hi @Bonno
awesome! Thanks for your work!

Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants