Jump to content

I Need a Little Help Getting My PHP Email Form Code to Display Correctly


Illustrator76

Recommended Posts

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 by Illustrator76
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.