Plaintext Not Showing Up In Backend

Not sure if that was the best way to word that title, but anyway…

I’m writing a PHP script that takes in user input through some form fields and automatically creates what should be a plaintext e-mail that is sent to a third-party, which has a server that processes the information in the e-mail. Here’s what I use to create the body of the e-mail:

[php] $email_message = htmlspecialchars("\n");
$email_message .= htmlspecialchars("\n");
$email_message .= htmlspecialchars(" <id sequence=“1” source=“NTW pop up”>\n");
$email_message .= htmlspecialchars(" “.date(“y-m-d”).“T”.date(“H:i:s”, time()).”\n");
$email_message .= htmlspecialchars(" <vehicle interest=“buy” status="".$condition."">\n");
$email_message .= htmlspecialchars(" “.clean_string($make).”\n");
$email_message .= htmlspecialchars(" “.clean_string($model).”\n");
$email_message .= htmlspecialchars(" \n");
$email_message .= htmlspecialchars(" \n");
$email_message .= htmlspecialchars(" \n");
$email_message .= htmlspecialchars(" <name part=“first”>".clean_string($first_name)."\n");
$email_message .= htmlspecialchars(" <name part=“last”>".clean_string($last_name)."\n");
$email_message .= htmlspecialchars(" “.clean_string($email_from).”\n");
$email_message .= htmlspecialchars(" <phone type=“voice” time=“morning”>".clean_string($phone)."\n");
$email_message .= htmlspecialchars(" \n");
$email_message .= htmlspecialchars(" \n");
$email_message .= htmlspecialchars(" Test Drive: “.clean_string($testdrive).”\n");
$email_message .= htmlspecialchars(" \n");
$email_message .= htmlspecialchars(" Price IT\n");
$email_message .= htmlspecialchars(" <name part=“full”>PriceITFormLead\n");
$email_message .= htmlspecialchars(" Price IT\n");
$email_message .= htmlspecialchars(" \n");
$email_message .= htmlspecialchars("\n");
$email_message .= htmlspecialchars("\n");[/php]

If I send the e-mail to myself, it shows up like this (which is correct):

12-06-20T20:36:18 Toyota Camry Test Test [email protected] 5551234567 Test Drive: June 22 Price IT PriceITFormLead Price IT

The third party’s server doesn’t process this as correct, even though if I send that same exact e-mail out, it works fine. From our end, looking on the server, it looks like it’s being seen correctly. But it’s not loading into the software. Somewhere in the processing end, we found that the server is actually seeing it as this:

<adf> <prospect> <id sequence="1" source="NTW pop up"></id> <requestdate>12-06-25T13:18:23</requestdate> <vehicle interest="buy" status="New"> <make>Toyota</make> <model>Camry</model> </vehicle> <customer> <contact> <name part="first">Test</name> <name part="last">Test</name> <email>[email protected]</email> <phone type="voice" time="morning">5551234567</phone> <postalcode></postalcode> </contact> <comments>Test Drive: June 22</comments> </customer> <vendor><vendorname>Price IT</vendorname></vendor> <provider><name part="full">PriceITFormLead</name> <service>Price IT</service> </provider> </prospect> </adf>

This tells me the formatting of the brackets and whatnot isn’t correct, but I’m not really sure how to do it correctly so that it shows up how I need it to. So my question is, how should I be doing this? Any help would be much appreciated!

Don’t use htmlspecialchars when creating the email. That changes it all to what you see above.

When I take out the htmlspecialchars, the e-mail shows up blank.

Is your email client on the server maybe setup to read mail as html and not txt?
Also don’t just think the email is blank, view the source of the email and check if the tags are there. It might be trying to display it as html.

Can you post you mail code here?
Specifically the part where you set your headers.

…yep, it was showing up as HTML but processed fine as text.

I’m just going to go on pretending this never happened.

Thanks for the help!

No problem.

And if anyone asks, just give them the typical software developer answer:

It worked yesterday. :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service