[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

php mail function - received message does not look right on Exchange, but looks fine on Apache

Posted on 2008-09-29
6
Medium Priority
?
284 Views
Last Modified: 2009-10-15
Hello Experts!

I am using the PHP mail() function to sumbit a form from the website to the client email.  The email looks perfect on a Linux mailbox, but received by an Exchange mailbox, I don't see the correct FROM information, and I can see all the html tags inside the email. I am pasting my code below.

Looking forward to your suggestions!!

<?php
$message1 = stripslashes("
<html>
<head>
 <title>Communication from website</title>
</head>
<body>                  
<table border='0' cellpadding='1' cellspacing='1'>
<tr align='left'><td colspan='2'><font size='+1'><b>Contact Us form from website</b></font><br><br></td></tr>
<tr><td align='right' class='gray12' valign='top'>First Name:&nbsp;</td><td>$first_name</td></tr>
<tr><td align='right' class='gray12' valign='top'>Last Name:&nbsp;</td><td>$last_name</td></tr>
<tr><td align='right' class='gray12' valign='top'>Company:&nbsp;</td><td>$Company</td></tr>
<tr><td align='right' class='gray12' valign='top'>Street Address:&nbsp;</td><td>$Street</td></tr>
<tr><td align='right' class='gray12' valign='top'>State:&nbsp;</td><td>$state0</td></tr>
<tr><td align='right' class='gray12' valign='top'>Zipcode:&nbsp;</td><td>$zipcode $plusfour</td></tr>
<tr><td align='right' class='gray12' valign='top'>Email:&nbsp;</td><td>$zipcode $email</td></tr>
<tr><td align='right' class='gray12' valign='top'>Phone:&nbsp;</td><td>$phone</td></tr>
<tr><td align='right' class='gray12' valign='top'>Interested:&nbsp;</td><td>$Interested</td></tr>
<tr><td align='right' class='gray12' valign='top'>Comments:&nbsp;</td><td>$comments</td></tr>
</table>
</body>
</html>
");

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .='From: '.$fname. ' '.$lname.'<'.$email.'>' . "\r\n";
$subj='Contact Us form from website';
//$from = "From: \"$fname $lname\" <$email>\nX-Mailer: PHP/" . phpversion;
mail('test@bscny.com', $subj, $message1, $headers);
?>
0
Comment
Question by:bscny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 11

Expert Comment

by:bansidhar
ID: 22598326
why are you stripping the slashes, your html code seems to be having no extra slashes to be stripped.

try using

message1 = "your html";
instead of
message1 = stripslashes("your html");
0
 

Author Comment

by:bscny
ID: 22598774
That didn't help. It shouldn't be the problem. I stripped slashes in case there are slashes in the submitted form.
0
 
LVL 11

Accepted Solution

by:
bansidhar earned 2000 total points
ID: 22603214
try changing
$headers .='From: '.$fname. ' '.$lname.'<'.$email.'>' . "\r\n";
to
$headers .='From: "'.$fname. ' '.$lname.'" <'.$email.'>' . "\r\n";

I cannot see any other problems. If this won't work please post the full mail header received by mail client. I can try to figure out the problem
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bscny
ID: 22662180
Hi bansidhar,

Didn't work still. I am about ready to give up. Outlook web access doesn't support showing headers, and since unfortunately I don't have control of this particular exchange server, I don't think I can get the headers out. I emailed the administrator; will have to see if he is able to get me the headers for the message.

Is it a common workaround to just strip out the html and settle for a plain text message?
0
 
LVL 11

Expert Comment

by:bansidhar
ID: 22666336
can you post the headers received by your mail client? I can try to figure out what is wrong from the standard header.
0
 
LVL 11

Expert Comment

by:bansidhar
ID: 22666343
why cant you try PHPmailer (http://phpmailer.codeworxtech.com/) it can handle maile much more efficiently and less coding issues.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question