Illustrator76 Posted June 10, 2016 Share Posted June 10, 2016 (edited) I am having trouble getting the email script code below to display correctly in all email clients. On my Outlook desktop client, it displays exactly how I want it to. The problem however is that on my mobile phone email client as well as my iPad Outlook email, the HTML elements in the code are showing up in the body of the email. So it is literally showing <p style='font=.....etc...> instead of styling the text like it is supposed to. Does anyone know how to fix this? Please note I am a novice at PHP and I simply found this code and tweaked it/added the HTML styling to fit what I needed. Any help given would be much appreciated. Thanks! $headers .= "From: $email\r\n"; $headers .= "Content-Type: text/html; charset=us-ascii\r\n"; $message = "<p style='font: 12px Arial, Helvetica, Sans-serif; color: #000;'>$name ($email), has contacted you through your site regarding $contact_me_selection.<br><br>\r\n <span style='font: 12px Arial, Helvetica, Sans-serif; font-weight: bold; color: #242424;'>Message:</span><br>\r\n<br>\r\n <span style='font: 12px Arial, Helvetica, Sans-serif; color: #000;'>$contact_me_text</span></p>\r\n"; $subject = "$name, Is Contacting You About $contact_me_selection"; function isInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } Edited June 10, 2016 by Illustrator76 Quote Link to comment https://forums.phpfreaks.com/topic/301323-i-need-a-little-help-getting-my-php-email-form-code-to-display-correctly/ Share on other sites More sharing options...
ginerjm Posted June 10, 2016 Share Posted June 10, 2016 Do those clients expect/accept html ? Quote Link to comment https://forums.phpfreaks.com/topic/301323-i-need-a-little-help-getting-my-php-email-form-code-to-display-correctly/#findComment-1533563 Share on other sites More sharing options...
Illustrator76 Posted June 10, 2016 Author Share Posted June 10, 2016 Do those clients expect/accept html ? I am assuming that they should, yes. Every other email that I get from every other source seems to come through just fine. I even just tried sending it in Rich Text and it did the same thing, so I assuming it has to be something wrong with this script. Quote Link to comment https://forums.phpfreaks.com/topic/301323-i-need-a-little-help-getting-my-php-email-form-code-to-display-correctly/#findComment-1533565 Share on other sites More sharing options...
Stefany93 Posted June 11, 2016 Share Posted June 11, 2016 (edited) What is the isInjected function for? Are you using PHPMailer? I don't have problems with it sending well encoded HTML emails and they appear very well on all platforms I have tested. Edited June 11, 2016 by Stefany93 Quote Link to comment https://forums.phpfreaks.com/topic/301323-i-need-a-little-help-getting-my-php-email-form-code-to-display-correctly/#findComment-1533572 Share on other sites More sharing options...
Illustrator76 Posted June 11, 2016 Author Share Posted June 11, 2016 I got it all sorted out guys. It was a combination of my headers being a bit off and some weird Outlook 2016 (desktop version) setting that I had to change in Microsoft WORD. Gotta love Microsoft for putting a setting that affects your email in a word document program. Quote Link to comment https://forums.phpfreaks.com/topic/301323-i-need-a-little-help-getting-my-php-email-form-code-to-display-correctly/#findComment-1533584 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.