Ecommerce Shopify WordPress Discussion

Invalid email headers using WordPress wp_mail()

I get an invalid header when I try to send an email using WP Mail SMTP, the test emails work fine. It has been working perfectly for months but from 25.01. it is not working. My code: $headers = "From: $email\n;"; $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8"; if (wp_mail($to, $subject, $message, $headers, $attachments)) { echo "<h3 style='color:green; text-align: center;'>Email sent!</h3>"; } Error thrown: invalid_parameter: Invalid headers
As the default character encoding for wp_mail() is UTF-8, you don't need charset=UTF-8 and also, the Mime version is not needed. So assuming that all other variables are correctly defined, try to use the following instead: $headers = "Content-Type: text/html;\r\n"; $headers .= "From: $email;\r\n"; if ( wp_mail( $to, $subject, $message, $headers ) ) { echo '<h3 style="color:green; text-align:center;">Email sent!</h3>'; } Tested and works in last WordPress version. I have removed $attachments argument… If you are using it, you can define it back.

February 4, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.