Page 1 of 1

Issue with mail code for application form

Posted: Wed Jul 08, 2009 10:59 pm
by fscproductions
I have put together an application form for a client, and set the form to the action of submission.php. In the submission.php file, I have the following code to process and format the application and shoot it to an email placed above my document html tags. Problem is, it is not sending me the form. On the application page, I have tried it with both GET and POST, as well as DEFAULT method, but not receiving the email.

Any help would be greatly appreciated.

Code: Select all

 
<?php session_start(); ?>
<?php
// Email the application details 
        
         $to = "email@address.com";
         $subject = 'Someone has requested title insurance';
         $message ="Below is a summary of their application <br />
                    <br />
                    
                    ---------transaction information-------------------<br />
                     Transaction Type: ".$_POST['transType']."<br />
                     Settlement Date: ".$_POST['settleDate']."<br />
                     Financing: ".$_POST['phone']."<br />
                     Cash: ".$_POST['cash']."<br />
                     Financing: ".$_POST['financing']."<br /><br>
                     
                     -----------Property Information----------------------<br />
                     
                     Property Address: ".$_POST['propertyAddress']."<br /><br />
                     
                     ----------------Buyer Borrower Information----------------------<br />
                     Name: ".$_POST['buyerName']."<br />
                     Address: ".$_POST['buyerAddres']."<br />
                     City: ".$_POST['buyerCity']."<br />
                     State: ".$_POST['buyerState']."<br />
                     Zip: ".$_POST['buyerZip']."<br />
                     Phone: ".$_POST['buyerPhone']."<br />
                     Email: ".$_POST['buyerEmail']."<br /><br />
                     
                     --------------Loan Information--------------------------<br />
                     New Loan Amount: ".$_POST['loanAmount']."<br />
                     Lender Name: ".$_POST['lenderName']."<br />
                     Loan Officer: ".$_POST['loanOfficer']."<br />
                     Street Address: ".$_POST['lenderAddress']."<br />
                     City: ".$_POST['lenderCity']."<br />
                     State: ".$_POST['lenderState']."<br />
                     Zip: ".$_POST['lenderZip']."<br />
                     Email: ".$_POST['lenderEmail']."<br />
                     Phone: ".$_POST['lenderPhone']."<br />
                     
                     -------------Seller Information---------------------------<br />
                     Name: ".$_POST['sellerName']."<br />
                     Address: ".$_POST['sellerAddress']."<br />
                     City: ".$_POST['sellerCity']."<br />
                     State: ".$_POST['sellerState']."<br />
                     Zip: ".$_POST['sellerZip']."<br />
                     Phone: ".$_POST['sellerPhone']."<br />
                     Email: ".$_POST['sellerEmail']."<br />
                     Does your property have an existing mortgage on it: ".$_POST['existingMortgage']."<br />
                     If so, who is lender: ".$_POST['previousLenderName']."<br />
                     Lender Phone: ".$_POST['prevLenderPhone']."<br />
                     Do you pay homeowner dues: ".$_POST['homeOwnerDues']."<br />
                     If yes, who do you pay: ".$_POST['homeownerDues_payto']."<br />
                     How much: ".$_POST['homeOwnerDues_amount']."<br />
                     Name of person ordering title Insurance: ".$_POST['orderName']."<br />;
                     Order Notes: ".$_POST['orderNotes'];
                     
                     
        //$from =$_POST['email'];
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= 'From: '.$_POST['buyerEmail'];           
         
//ALL THE PROCESSING IS DONE SEND THE EMAIL
 
         mail($to,$subject,$message,$headers);
 
        
?>
 

Re: Issue with mail code for application form

Posted: Thu Jul 09, 2009 9:25 am
by Skara

Code: Select all

$headers .= 'From: '.$_POST['buyerEmail'];
is susceptible to email injection...

Have you tried just running

Code: Select all

mail('youremail@example.com','test','test message',$headers);
?? If that doesn't work, it's a problem with your php.ini, and/or sendmail / smtp server/settings.

Re: Issue with mail code for application form

Posted: Thu Jul 09, 2009 6:33 pm
by fscproductions
Ok, I took out all the header reference, and just used the mail and I received the email from an anonymous email addres from my server host. So the error is obviously in the header values. But none of the info is formatted, which is important. Any suggestions on a good way to get the header info to display properly in this?

The weird thing is, this code is cut from two subscription forms for other websites, and they work fine. I just cut it from there and made some changes, but now is giving me an issue.

Re: Issue with mail code for application form

Posted: Thu Jul 09, 2009 7:44 pm
by Skara
I just cut it from there and made some changes, but now is giving me an issue.
I don't know what your changes were, but if it makes sense to do so, start over. Get what you started with and make one change at a time until you get an error.

Sorry, but I don't see an error right off the bat. Some other ideas...
- Right before mail()ing, echo all variables to the screen to see what you're dealing with. Something may not be what you think it is.
- Try replacing $message with a simple $message = "test<br />\r\ntest\r\n";
- Try adding an extra \r\n on the end of $headers?
- Try taking out the mime-type and send it plaintext.

Re: Issue with mail code for application form

Posted: Fri Jul 10, 2009 8:41 pm
by fscproductions
Thanks for all the ideas. I finally got the form to work, and just in case anyone else has a question about mail headers I found the outline of common mail header functions here:

http://us.php.net/manual/en/ref.mail.php

The email was received, just working on the from variable, because that is coming in as anonymous. So I was scanning the php site, and found the header info.