Oops….the WordPress update broke my contactforms
51153
post-template-default,single,single-post,postid-51153,single-format-standard,select-core-1.2.1,brick-child-child-theme-ver-1.0.0,brick-theme-ver-3.4,ajax_fade,page_not_loaded,smooth_scroll,side_menu_slide_from_right,vertical_menu_enabled,vertical_menu_left,vertical_menu_width_290,wpb-js-composer js-comp-ver-6.4.1,vc_responsive
broken contactform mail

Oops….the WordPress update broke my contactforms

One of the things i often have to implement on WordPress websites is contact-forms with a mail function.
Most of the time, I implement Contactform 7 because it is easy to comprehend for my customers and the function validation to get the emails sent to my customers’ email addresses, works fairly well.

Recently WordPress released version 4.6 and it had one Nasty surprise for me…… contact-forms suddenly didn’t work anymore.
Because this happened when I was handing over a website to a customer, I was wondering whether i had made a typo…

I hadn’t.

The wp_mail() function, which is being used by almost everything that wants to send emails from a WordPress website, according to the change log has been changed.

In 4.6 (see r38058) we changed how we apply the from email and name, we now use PHPMailers own setFrom()function call.

Sadly it has proven to be buggy. The good news is that it has been solved and a correct working function will be released with 4.6.1.

Until you can implement the 4.6.1. release in production, here’s the quickfix that solves your problem for now, however with a downside; you won’t be able to send attachements.

For Contactform 7:

I changed the wp_mail() function to mail() and removed $attachments. This is working for my setup with contact-form-7 4.5 and wordpress 4.6. Obviously without attachments.

see /wp-content/plugins/contact-form-7/includes/mail.php (Line 85)

old:

 return wp_mail( $recipient, $subject, $body, $headers, $attachments );

new:

return mail( $recipient, $subject, $body, $headers );

Change it back once you have implemented 4.6.1. and verified that it works as expected.

Hope this helps

R.