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.
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?