Whenever mails are triggered from a WordPress site, a few alphabets are randomly getting replaced with '=' in the mail content. I have set the charset and content type in headers even then this weird error is coming. What could be the possible fix to this ?
Below is my code to trigger mails from a WordPress site:
$footerText = "<br/><br/> Regards,<br/> ABC<br/><br/> Note: This is an automated mail. Please do not reply to this message"; $post = get_post($postId); $post_date = strtotime($post->post_date); $author_email = get_the_author_meta( 'user_email', $post->post_author); $headers = array(); $headers = 'Content-type: text/html; charset=UTF-8'; $headers = 'From: '.FROM_EMAIL; //$headers = 'Bcc: '.$author_email; $subject = "Request to share your expertise on - '".$post->post_title."'"; $post_title = $post->post_title; $post_content = $post->post_content; $post_url = get_permalink($post->ID); $mail_message = "Your expertise would help solve complex business problems that would help our associates solve our client problems faster. Request you to share your expertise on the following post, which has not been answered for over ".$days." days now.<br/><br/> Post: <strong>".$post_title."</strong><br/> Description: ".$post_content."<br/><br/> Click <a href='".$post_url."'>here</a> to respond to the post.<br/><br/> Thanks You! ".$footerText; $hello_text = "Dear Expert,<br /><br />"; $full_message = $hello_text.$mail_message; wp_mail('firstname.lastname@example.org',$subject,$full_message,$headers);
Emails that i receive using this code is as follows:
Your expertise would help solve complex business p=oblems that would help our associates solve our Cli=nt(s) problems faster. Request you to share your experti=e on the following post, which has not been answered for o=er 8 days now.
Post: RFP for Business De=elopment,Functional Testing,Technology Expert,Perfecto,Healthcare,Medical =anagement,Mobile,Digital,North America This is Dynamic content, retrieved from database
Description: Customer is asking f=r RFQ to develop a new mobile app for care management application in AHM. =HM is a subsidary of Aetna Inc. This is Dynamic content, retrieved from database
Click here to respond to the post.
Note: This is an automated mail.=lease do not reply to this message
Totally confused on why random letters are getting replaced with '='.Kindly point out and suggest what is wrong with this