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 DMA for sending email #217

Closed
wants to merge 2 commits into from
Closed

Conversation

moqmar
Copy link

@moqmar moqmar commented Oct 28, 2020

Summary

Implement solution for email sending, as discussed in #204.

This PR implements the following features

  • Install DMA
  • Make DMA configurable via environment variables
  • Document DMA usage

Explain the motivation for making this change. What existing problem does the pull request solve?

Most PHP hosters make the "mail()" function usable, so many PHP application expect it to be usable. With this image, those applications were unable to send email.

Test plan (required)

  1. docker build -t thecodingmachine/php:7.4-v3-slim-apache -f Dockerfile.slim.apache --build-arg "PHP_VERSION=7.4" --build-arg "GLOBAL_VERSION=v3" .
    This failed with No composer.json present in the current directory, this may be the cause of the following exception., but this doesn't seem to be related to this PR. Commenting out Prestissimo (L139-144 in Dockerfile.slim.apache) works as a workaround.
  2. docker build -t thecodingmachine/php:apache -f Dockerfile.apache --build-arg "PHP_VERSION=7.4" --build-arg "GLOBAL_VERSION=v3" .
    This failed with chmod: cannot access '/var/lib/snmp/mib_indexes': No such file or directory, but this doesn't seem to be related to this PR. Adding || true to the last line in extensions/core/snmp/install.sh works as a workaround.
  3. echo "<?php mail('[email protected]', 'Hello World', 'This is a test');" > /tmp/test.php
  4. docker run --rm -it --name dma-test -p 8080:80 -v "/tmp/test.php:/var/www/test.php" thecodingmachine/php:apache
  5. curl localhost:8080/test.php
  6. Check if the email arrived (for the email address used above this can be done at https://www.mohmal.com/en).
  7. docker run --rm -d --name dma-test -e "[email protected]" -e "DMA_CONF_SMARTHOST=smtp.postmarkapp.com" -e "DMA_AUTH_USERNAME=test" -e "DMA_AUTH_PASSWORD=test" thecodingmachine/php:apache && sleep 2 && docker exec dma-test sudo cat /etc/dma/dma.conf /etc/dma/auth.conf; docker stop dma-test

Closing issues

Fixes #204

Checklist

  • Have you followed the guidelines in our CONTRIBUTING guide?
  • I have squashed any insignificant commits
  • This change has comments for package types, values, functions, and non-obvious lines of code

@moqmar
Copy link
Author

moqmar commented Oct 28, 2020

It should work that way, but I'll test everything tomorrow again and will then add a test plan.

@moqmar
Copy link
Author

moqmar commented Oct 30, 2020

Alright, I've added a test case & solved some small but evil build errors. Let me know if you need anything else. 🙃

@thibodelanghe
Copy link

thibodelanghe commented Nov 7, 2020

@moqmar The composer.json error is probably related with that composer v2 is now used as a default instead of 1.x which breaks things.

edit: There's a PR for it #219

@moqmar
Copy link
Author

moqmar commented Nov 7, 2020

Awesome that there's a PR for that now, I though I've overlooked some build requirement or something. This just leaves the chmod: cannot access '/var/lib/snmp/mib_indexes': No such file or directory error... 😕

Should I add my workaround (|| true) as a commit here? I guess if the directory doesn't exist, the permissions don't matter, but maybe it'd be better to try and create the directory before? Would be generally good to know what that directory is for and when it should be created.

@thibodelanghe
Copy link

I have no idea what could be the cause for that error. Maybe @npeguin, @nguyenk or @moufmouf knows whats up?

@stale
Copy link

stale bot commented Nov 9, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please update it if any action still required.

@stale stale bot added the stale Issues inactives for a while (automatically) label Nov 9, 2021
@stale
Copy link

stale bot commented Nov 16, 2021

This issue has been automatically closed because it has not had recent activity. Please, reopen if you need.

@stale stale bot closed this Nov 16, 2021
@moqmar
Copy link
Author

moqmar commented Feb 7, 2022

Alright, I have rebased & updated the branch now, this can definitely be re-opened, but isn't yet ready for merge again. The build seems to work now, but I'll have to check the configuration again, and would like to make sure that log messages are at least shown somewhere:

  • docker build -t thecodingmachine/php:8.1-v4-slim-apache -f Dockerfile.slim.apache --build-arg "PHP_VERSION=8.1" --build-arg "GLOBAL_VERSION=v4" . ➜ succeeds
  • docker build -t thecodingmachine/php:8.1-v4-apache -f Dockerfile.apache --build-arg "PHP_VERSION=8.1" --build-arg "GLOBAL_VERSION=v4" . ➜ succeeds
  • 1. echo "<?php mail('[email protected]', 'Hello World', 'This is a test');" > /tmp/test.php
    2. docker run --rm -it --name dma-test -p 8080:80 -v "/tmp/test.php:/var/www/html/test.php" thecodingmachine/php:8.1-v4-apache
    3. curl localhost:8080/test.php
    4. ➜ mail is stuch in queue
  • docker run --rm -d --name dma-test -e "[email protected]" -e "DMA_CONF_SMARTHOST=smtp.postmarkapp.com" -e "DMA_AUTH_USERNAME=test" -e "DMA_AUTH_PASSWORD=test" thecodingmachine/php:8.1-v4-apache && sleep 2 && docker exec dma-test sudo cat /etc/dma/dma.conf /etc/dma/auth.conf; docker stop dma-test
    SMARTHOST smtp.postmarkapp.com
    test|smtp.postmarkapp.com:test
    
    ➜ config looks as expected, but mails still stuck in queue

@moqmar
Copy link
Author

moqmar commented Feb 7, 2022

Ah, I can't change the target branch, right, so I have to create a new one?

@mistraloz
Copy link
Collaborator

Yes create a new one please. There is also some mistakes,

1/ Please change the blueprint files here :
/utils/*.blueprint (the bases Dockerfiles and README.md are generated from theses so it's may reverted by any new changes).
You can play blueprint with command make blueprint (after install of orbit ).
If it's easier for you, i can play orbit on your PR but implement your changes in blueprints please.

2/ Please also implement somes tests cases in build-and-test.sh files. Just add some cases (i suggest usage of http://ethereal.email/ for testing auth config).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues inactives for a while (automatically)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sending mail
3 participants