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

Mailpit not getting emails on automatic addition of PHP 8.4.5 #1092

Closed
dbarproductions opened this issue Mar 22, 2025 · 6 comments
Closed

Mailpit not getting emails on automatic addition of PHP 8.4.5 #1092

dbarproductions opened this issue Mar 22, 2025 · 6 comments
Assignees
Labels
Milestone

Comments

@dbarproductions
Copy link

I bought the "lifetime" license for version 7, and am happy to support your great work!
I was excited about the automatic addition of new PHP versions in version 8 which I installed yesterday. However, I can't get Mailpit to catch any emails from my WordPress sites/projects with PHP 8.4.5 which was automatically installed shortly after I launched Laragon 8. This was installed over my version of Laragon 7. If I switch back to PHP 8.4.2, it works fine. I tried copying the same mail settings from the 8.4.2 php.ini file to the 8.4.5 php.ini file, but still no luck. So, right now I have to use 8.4.2 for testing of any emails in the plugins I'm working on.

@dbarproductions
Copy link
Author

If I look at the log file in the mailpit folder, I see this:
time="2025/03/21 18:12:37" level=fatal msg="listen tcp 0.0.0.0:1025: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."

@leokhoa leokhoa self-assigned this Mar 24, 2025
@leokhoa leokhoa added the bug label Mar 24, 2025
@leokhoa leokhoa added this to the Laragon 8.1 milestone Mar 24, 2025
@leokhoa
Copy link
Owner

leokhoa commented Mar 24, 2025

@dbarproductions: Thank to your support Laragon is getting better.
Laragon should auto-configured mailpit when you switch PHP versions. The log from Mailpit said that you can't run 2 instances of Mailpit on the same port. It is not the root cause of the issue.
I have tested and it is OK in my case. Can you please provide the sendmail_path in php.ini?

sendmail_path="C:/laragon/bin/mailpit/1.22.3/mailpit.exe sendmail"

To test: create a test.php with this content:

<?php
mail('[email protected]','Test subject', 'Test message', '');

Open Laragon terminal and run:

php PATH-TO/test.php

To ensure PHP version, type:

php --version

@dbarproductions
Copy link
Author

OK... so I created the test file in the root of one of my wordpress project directories. When I run it from the browser, I don't get an email. If I open terminal, change to that directory, and run it, then I get the email in mailpit.
I might try a fresh install of Laragon 8 in a new directory. I installed it over the top of Laragon 7 in my C://laragon7 directory. I can't remember if Laragon 7 had mailpit bundled with it, or if I manually added it following the instructions I found through another user here. But, I have double-checked the php.ini file, and it seems correct. I removed the older versions of mailpit in the /bin directory. I even removed the entries to autostart/load it in the laragon proc file, and before testing this morning I removed the old entry in the hosts file. Here's my current relevant section for php.ini for 8.4.5
[mail function] ; For Win32 only. ; https://php.net/smtp SMTP=mailpit ; https://php.net/smtp-port smtp_port=1025 ; For Win32 only. ; https://php.net/sendmail-from [email protected] ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; https://php.net/sendmail-path sendmail_path="C:/laragon7/bin/mailpit/1.22.3/mailpit.exe sendmail" ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(). ;mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename mail.add_x_header=Off ; Use mixed LF and CRLF line separators to keep compatibility with some ; RFC 2822 non conformant MTA. mail.mixed_lf_and_crlf=Off ; The path to a log file that will log all mail() calls. Log entries include ; the full path of the script, line number, To address and headers. ;mail.log = ; Log mail to syslog (Event Log on Windows). ;mail.log = syslog

Note that the sendmail path IS correct for my current install, which was over the top of Laragon 7. This is basically the same php.ini section that I have for PHP 8.4.2, which works fine. It just doesn't work with PHP 8.4.5 for some reason. I did notice that the PHP 8.4.5 version that was installed seems to be the NTS version, whereas my other versions don't have the NTS in the file names or after the version number that shows at the top of Laragon.

Here is the current hosts file that I tested with this morning after deleting the old entry for mailpit:
`# Laragon magic

Local - Start

::1 sherrard-racks.local #Local Site
127.0.0.1 sherrard-racks.local #Local Site
::1 www.sherrard-racks.local #Local Site
127.0.0.1 www.sherrard-racks.local #Local Site

Local - End

127.0.0.1 demo.test #laragon magic!
127.0.0.1 ssplugins.test #laragon magic!
127.0.0.1 volunteer.test #laragon magic!
127.0.0.1 watersideresidents.test #laragon magic!
127.0.0.1 woocom.test #laragon magic! `

It's got some old entries from when I was trying out Local, but I don't think that will affect anything.
I'll see what happens if I install Laragon 8 in a new directory now and let you know if it works that way.

@dbarproductions
Copy link
Author

Just installed Laragon 8 in a fresh directory. Made sure to kill the old mailpit.exe process from the task manager first (it never gets shut down unless you manually end it). I didn't touch anything from the default install. Waited for Laragon 8 to do the automatic update to PHP 8.4.5, and then did a quick add of a WordPress project, and installed one of my plugins that has a simple email function for emailing users. No luck. First, I didn't get the usual email when a new WordPress site is created after setup. And then my test email never came through either. Note, that this is the default entry created for the 8.4.5 php.ini file when it installs automatically (I did NOT change anything):
[mail function]
; For Win32 only.
; https://php.net/smtp
SMTP=localhost
; https://php.net/smtp-port
smtp_port=25
; For Win32 only.
; https://php.net/sendmail-from
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; https://php.net/sendmail-path
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail().
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header=Off
; Use mixed LF and CRLF line separators to keep compatibility with some
; RFC 2822 non conformant MTA.
mail.mixed_lf_and_crlf=Off
; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =
; Log mail to syslog (Event Log on Windows).
;mail.log = syslog
sendmail_path="C:/laragon/bin/mailpit/1.22.3/mailpit.exe sendmail"

And I still got the same 2 errors in the mailpit.log file, I'm assuming the first from the email when a new site is set up, and the second from my test email. Note that WordPress thinks the email has been sent as the wp_mail function in WordPress is not returning false (I have success/error messages in my plugin depending on what wp_mail returns).
time="2025/03/24 11:03:26" level=fatal msg="listen tcp 0.0.0.0:1025: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."
time="2025/03/24 11:04:30" level=fatal msg="listen tcp 0.0.0.0:1025: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."

@leokhoa
Copy link
Owner

leokhoa commented Mar 25, 2025

@dbarproductions : There are 2 points:

  1. You can use mailpit with Terminal but not browser
  2. Your PHP 8.4.2 is TS version

From the you can test with TS version. You can add a new PHP version using Menu > Tools > Quick add:

php-8.4.5-ts=https://windows.php.net/downloads/releases/php-8.4.5-Win32-vs17-x64.zip

@dbarproductions
Copy link
Author

I didn't see any way to add a new PHP version via the Tools > Quick add. But, I downloaded the TS version of PHP 8.4.5, and laragon added the mailpit path when I switched to it, and I can verify that mailpit now receives emails from WordPress and the browser. Not sure why the NTS version doesn't work, but since my older PHP versions are also TS, I'll just stick to installing manually as new versions become available.
Thanks for your help and the great software!

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

No branches or pull requests

2 participants