Mailpit Not Capturing emails

Mailpit is not intercepting emails

I am able to capture the information from the form to a php function to send a test email to Mailpit.

       $admin_email = get_bloginfo('email');

        $headers = [];
        $headers[] = "from: " . get_bloginfo('name') . $admin_email;
        $headers[] = "reply-to: {{$_POST['first-name']}} <{{$_POST['email']}}>";

        $subject = "New form submission from {$_POST['first-name']}";

        $message = "";
        $message .= "Form has been received from {$_POST['first-name']} <br><br>";

        foreach ($_POST as $label => $value) {
            $message .= ucfirst($label) . ": " . $value;
        }

  Do I need to set up certain headers to communicate with MailPit?



System Details

  • Local Version: 9.0.5

  • Operating System (OS) and OS version: Windows Pro 10 Version 10.0.19045



Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

Hi @ehr-local

You shouldn’t need to set up anything additional to communicate with Mailpit but there could be a conflict at play somewhere.

Could you share your Local Log here for us? Retrieving Local’s Log File

Sure thing, thanks for looking into this.
local-logs.zip (97.6 KB)

There doesn’t appear to be much in the logs as far as recent errors. Is there anything unique about the configuration for this site?

For example if you create a new, blank site in Local for example and try to do something like a password reset does that pass through to Mailpit?

I’m using Carbon Fields. I’ll check to see if it works for a blank site.

1 Like

Hey @ehr-local – I see that the code is collecting the form fields, but I’m not seeing it ever send the email.

Local’s Mailpit feature will capture any emails that are sent via PHP’s mail() function. Since you’re building this is WordPress, I’d recommend using WordPress’ wp_mail() function which uses PHP’s mail() function under the hood as well as allows the various parameters to be filtered by plugins or themes.

Can you try adding either of those functions and seeing if that allows you to see emails within Mailpit?

2 Likes

Sorry I missed copying the part of the code where it sends the email using wp_mail function. it is working now. I tracked down my typo.

3 Likes

thanks for your assistance. I tracked down the typo. its working now

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.