Send mail subject line converts html entities to charecters

Posted: May 26, 2012 in WordPress

Many of us might have encountered this issue, seems small but creates major impact. Both Php and WordPress send mail
method will converts subject line’s html entities such as (single quotes), ( double quotes ), ( @ ), ( ! )…. into characters while sending mail.

I got solution for this issue, I used html_entity_decode() function to get rid off this issue.

    
       wp_mail( $to, stripslashes_deep( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ) ), $message );
    

Parameters Description:
Returns a string with backslashes stripped off. (\’ becomes ‘ and so on.) Double backslashes (\\) are made into a single backslash (\).

UTF-8: Defines character set ENT_QUOTES will converts both double and single quotes.

Advertisements
Comments
  1. Ganesh Kerkar says:

    This is awesome, Thanks a lot Sandeep for writing this Post.

    Thankyou once again and keep writing good posts like this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s