-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Sending emails from PHP container to Mailpit running in another container does nothing #153
Comments
Considering you're running Mailpit in verbose mode, what output are you getting from the Mailpit container when you try connect/send from the PHP container? I think it's one of a few things: Firstly, is there are particular reason you're including Secondly, what You should be able to test PHP's mail() in verbose mode like this:
If you're getting errors similar to that bug report I linked to, then you will probably need to replace sendmail with a compliant sendmail version. Lastly, I assume
is a typo? It should be just I hope this helps and that you're able to debug your issue. |
Sendmail is at least this container Alpine's BusyBox v1.36.1 php -d "sendmail_path=/usr/sbin/sendmail -v -S host.docker.internal:1025 -t" -r 'mail("[email protected]", "Test subject", "This is our test message", "From: [email protected]");' gives failed at the end:
|
Your output looks identical to #87 - this is not a Mailpit bug, it looks like the same busybox sendmail bug likely caused by As a work-around for the buggy sendmail, you could set your existing sendmail as such:
The You can test this with:
|
Workaround seems to work, I tested it on a few projects. Problem still persists on projects where we are not the authors of the PHP Docker images used and if they don't support changing sendmail configuration with |
Whilst I understand your issue (not always having control over the docker images used), this is appears to still be an issue with this sendmail implementation, which is sending non-RFC-compliant headers to Mailpit (or any SMTP server for that matter). In my view, Mailpit is doing exactly what is was mean to - it is (among other things) an SMTP testing tool too, and so it isn't accepting a non-compliant SMTP connection. The problem should be fixed upstream, ie: in busybox's sendmail, which would then resolve the issue everywhere once fixed and rolled out. I have just reported the issue in their bug tracker, so we'll see what happens there and what their response is. I will still look in the meantime whether there is a work-around for Mailpit (to accept the non-compliant headers), however last time I looked it didn't seem possible, and as I just said, it defeats the point of testing SMTP if it allows non-compliant headers. |
You mention in #87 alternative sendmail available for Alpine being |
That was (from memory) a replacement, but not sure about it being "drop-in". But ... before you continue - I have been looking into a working solution. The workaround (I haven't released this yet) will resolve the issue for you, with an option to turn it off. I'm not 100% happy about "fixing" messages by default, but with careful consideration I think that this is the better approach as it's clear that this is a blocker for many developers who use busybox's sendmail implementation in testing. Most users, like yourself, will just get an error and not understand what the actual problem is, and some major mailservers like postfix already auto-correct this anyway. I expect to have this "feature" released in the next couple of days. |
I have just released this "fix" in v1.8.2. Please let me know if it resolves your sending error? |
Just tried it: It works IF I change the php.ini sendmail setting from |
Ahh yes, the Glad it's working! |
Yes! Thank you for the support, I can now add Mailpit as Mailhog replacement in our tooling and projects just need to add that |
We are replacing MailHog with Mailpit in our tool Stohenge: druidfi/stonehenge#76
We have a problem getting email sent from PHP containers to host's port 1025. Noteworthy is that sending emails with curl from those same containers work just fine which I guess at least verifies that Mailpit is running just fine. When sending email through PHP (sendmail), we get no errors to logs or on terminal.
This is current setup & situation from the PR above ^^:
Mailpit is attached to
localhost:1025
from a Docker container and is running with following flags:Contents of
email.txt
:Works
Sending email from host (macOS) with Curl:
Sending email from another container with Curl:
Not working:
Sendmail configured for PHP as inside another container:
Sending email from another container with PHP
mail()
function:php -r 'mail("[email protected]", "Test subject", "This is our test message", "From: [email protected]");'
The text was updated successfully, but these errors were encountered: