Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Avinash Kumar Sharma

    (@avi1020p)

    Hello @sergefcleantalk ,

    Thank you for your suggestion, and apologies for the delayed response.

    After reviewing the code, we can confirm that the pre_wp_mail filter is already implemented in the plugin. You can see it in the Mail Handler file here:
    https://plugins.trac.wordpress.org/browser/suremails/trunk/inc/emails/handler/mail-handler.php

    Please refer to line 103 in that file where the filter is being used.

    We appreciate you taking the time to review the code and share your suggestion. Feedback like this is always valuable for improving the plugin. If you have any additional suggestions or questions, please feel free to share them.

    Best regards,
    Avinash

    Thread Starter sergefcleantalk

    (@sergefcleantalk)

    Hello
    Thank you for your reply.

    There may be a small misunderstanding about how pre_wp_mail is used.

    Current situation
    In mail-handler.php around line 103, SureMail applies the filter:
    $pre_wp_mail = apply_filters( ‘pre_wp_mail’, null, $atts );
    That runs inside <code class=””>MailHandler::process_mail() and checks whether another plugin has already short-circuited the call. It does not add a pre_wp_mail callback for SureMail itself.

    Why SureMail’s handler often never runs
    In suremails.php (around lines 55–69), SureMail only defines wp_mail when it doesn’t already exist. In standard WordPress, pluggable loads before plugins, so when SureMail loads, wp_mail usually already exists. In that case, SureMail never defines its own wp_mail, so <code class=””>MailHandler::handle_mail() (and logging) never runs. SureMail’s behaviour therefore still depends on plugin load order.

    Proposed fix
    Add a pre_wp_mail filter when wp_mail already exists so SureMail can intercept all calls. Keep the current wp_mail definition only for the rare case when it doesn’t exist.

    With this approach, SureMail’s MailHandler and logging run regardless of plugin load order.
    More details and a full example are in this gist: https://gist.github.com/svfcode/790f2dc6e6f4aab0688e9f58dce92d4b

    Best regards

    Thread Starter sergefcleantalk

    (@sergefcleantalk)

    Why did you mark the issue as resolved without consensus?

    Plugin Support Avinash Kumar Sharma

    (@avi1020p)

    Hello @sergefcleantalk,

    Since there was no reply earlier, the topic was marked as resolved before your response on March 16.

    That said, thank you very much for taking the time to share such detailed and thoughtful feedback. We truly appreciate it.

    We’ve reviewed the codebase again and confirmed that your point is completely valid. Adding a pre_wp_mail filter to ensure interception when wp_mail is already defined, while keeping the current fallback, is indeed a great approach to make the behavior more consistent. Your insight here is genuinely valuable.

    Our development team is actively reviewing this and looking forward to implementing improvements based on your suggestion. Contributions like yours really help us improve the product for everyone.

    We also sincerely apologize for any confusion caused by the topic status. It was not our intention to close the discussion prematurely, and you’re always welcome to continue sharing your thoughts.

    We’d love to hear more suggestions from you whenever you have them. Your expertise and attention to detail truly make a difference!

    Warm regards,
    Aviansh

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.