Make WordPress Core

Opened 20 months ago

Closed 11 months ago

Last modified 5 weeks ago

#63135 closed feature request (wontfix)

Testing and Debugging WP_Mail related topics

Reported by: SirLouen Owned by: SirLouen
Priority: normal Milestone:
Component: Build/Test Tools Version:
Severity: minor Keywords: has-patch has-test-info
Cc: Focuses:

Description

How do you test and debug things related to WP_Mail with wordpress_develop?

Unless I'm missing something in the code, I think that having an optional runnable Mailhog instance could be pretty neat for testing and debugging purposes.

Maybe there are some other proposals or ideas that I would like to know, but meanwhile I will be uploading a patch with Mailhog idea.

Change History (26)

This ticket was mentioned in ​Slack in #core-test by sirlouen. ​View the logs.


20 months ago

This ticket was mentioned in ​PR #8555 on ​WordPress/wordpress-develop by ​@SirLouen.


20 months ago
#2

  • Keywords has-patch added

Adding support for a mailhog container on demand with the env variable: LOCAL_MAILHOG

Patch Testing instructions:

  1. Change LOCAL_MAILHOG=false to LOCAL_MAILHOG=true in your .env file
  2. Run your docker environment as usual npm run env:start
  3. You test if your mailhog instance is running with either:

A) Go to ​http://localhost:8025/
B) You can run in your wordpress-develop container

docker exec -it  wordpress-develop-php-1 openssl s_client -connect mailhog:1025

And it might result in something like:

CONNECTED(00000003)
135865530688832:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../ssl/record/ssl3_record.c:331:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 5 bytes and written 283 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)

C) You can do further tests, like sending an email with a plugin that uses the local mailhog hostname
For example this one: ​https://github.com/SirLouen/amazon-s3-email-testing/archive/refs/tags/1.0.0.zip

Trac ticket: https://core.trac.wordpress.org/ticket/63135

#3 @SirLouen
20 months ago

  • Keywords needs-testing has-testing-info added

Ready for testing

#4 @SergeyBiryukov
19 months ago

  • Milestone Awaiting Review → 6.9

This ticket was mentioned in ​Slack in #core-test by sirlouen. ​View the logs.


18 months ago

#6 @wordpressdotorg
18 months ago

  • Keywords has-test-info added; has-testing-info removed

This ticket was mentioned in ​Slack in #core-test by sirlouen. ​View the logs.


18 months ago

This ticket was mentioned in ​Slack in #core-test by sirlouen. ​View the logs.


18 months ago

#9 @nikunj8866
18 months ago

  • Keywords needs-testing removed

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/8555

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 136.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Eleven 4.9
  • MU Plugins: None activated
  • Plugins:
    • Amazon S3 Email Testing 1.0.0
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch.

Supplemental Artifacts

​https://ibb.co/WNw5yQWf

#10 @SirLouen
18 months ago

  • Keywords dev-feedback added

#11 @johnbillion
18 months ago

  • Version trunk

#12 @audrasjb
17 months ago

  • Type enhancement → feature request

#13 @SirLouen
16 months ago

  • Keywords needs-unit-tests added; dev-feedback removed

Switching into Mailpit. It providers a better API for testing.
I will set a little suite of integration tests to showcase this.

#14 @SirLouen
16 months ago

  • Component Build/Test Tools → Mail

​@mindctrl commented on ​PR #8555:


16 months ago
#15

@SirLouen is there anything left to do here?

​@SirLouen commented on ​PR #8555:


16 months ago
#16

@mindctrl yeah this is still of phase 1.
But I'm using this mainly to drag it as a patch and test reports that need something relating with Mail component.
I don't think it will get through as-is right now.

​@mindctrl commented on ​PR #8555:


15 months ago
#17

@SirLouen could you add a list of things left to do in the opening description? We have a 6.9 milestone and I'd love to help get it in the proper state for a committer to review/merge. I've needed local mail testing multiple times recently. WCUS Contributor Day is coming up and I know a few people willing to help.

​@SirLouen commented on ​PR #8555:


15 months ago
#18

@mindctrl I think it's time to de-milestone this. I was confident that this could be a great addition to wordpress-develop, but for now it's not adding value in the line that is expected (according to one dev-chat some months ago)

My idea is to look to add extra value to this, but this is not going to happen anytime soon, and I seriously doubt it will make it on time for 6.9. This PR by itself is useful for someone like me that uses this PR like every other day, but useless for most of the people that seldom test anything—mail. Hope to see it merged somewhere in the future, but much work is needed to consider it a potential merge (mainly creating integration tests in PHPUnit that make use of this service).

I've updated the milestone so we don't need to rush it anymore.

#19 @SirLouen
15 months ago

  • Milestone 6.9 → Future Release

Moving into Future Release for the reasons stated above. No need to rush it for now.

#20 follow-up: @jorbin
15 months ago

  • Keywords close added

I think this may be a duplicate of #48060. While that originates with a different suggestion, the most recent on the ticket is for MailHog.

#21 in reply to: ↑ 20 @SirLouen
14 months ago

  • Component Mail → Build/Test Tools
  • Keywords needs-unit-tests close removed
  • Milestone Future Release → 6.9
  • Owner set to SirLouen
  • Status new → assigned

Replying to jorbin:

I think this may be a duplicate of #48060. While that originates with a different suggestion, the most recent on the ticket is for MailHog.

Thanks for that one, it true, and it's good to see that it has been solicited and there is plenty of interested.

But this ticket is much more advanced in progression in all regards, so I'm going to be closing that in favor of this one. I'm moving back to 6.9, I really want to see this anytime soon. It's definitely a pain to test for the Mail component.

I've been using this for over 4 months (patching on demand). The switch from Mailhog to Mailpit is significantly favorable. Maybe some tweaking is required to be more compliant with the current state of docker-composer.yml, although we have to keep simple the container name to be easy to target with the PHPMailer SMTP injection.

#22 @SirLouen
14 months ago

#48060 was marked as a duplicate.

This ticket was mentioned in ​Slack in #core by sirlouen. ​View the logs.


13 months ago

#25 @wildworks
13 months ago

  • Milestone 6.9 → Future Release

6.9 Beta1 will be released soon, but this ticket seems to be about improving core development itself. I don't think it's a necessary task for the 6.9 release, so I will change the milestone to Future Release again.

#26 @SirLouen
11 months ago

  • Milestone Future Release
  • Resolution → wontfix
  • Status assigned → closed

With this in place #63564 and docker-composer.override.yml this is not necessary anymore.

#27 @afercia
5 weeks ago

@johnbillion @desrosj @jorbin can we reconsider this request?

I recently had the need to test the user / administration emails change flows in the admin. I had to do some extra work just to test the sent emails. The developer experience should be effortless when testing features involving emails and should not require extra steps.

I ended up using docker-compose.override.yml to add the Mailpit container, using basically the same config used in ​https://github.com/WordPress/wordpress-develop/pull/8555

Then, I had to use a small plugin to:

  • Hook into wp_mail_from to force WordPress to generate a valid domain pattern for the From address.
  • More importantly: hook into phpmailer_init to route the local emails to the Mailpit container.

All of the above should not be required just to test Core features.

The request for a mail catcher container seems to be pretty common, see #49305 and #48060.

Note: See TracTickets for help on using tickets.