Sandwich Artist
Posts: 25
186 credits Members referred : 0
« on: Mar 05, 2008, 06:53:04 PM »
I'm trying to email a pdf attachment through php's mail function and the email comes through with the attachment intact yet the body of the email doesn't come through. The email I'm adding this attachment to has been in use for a while just needed to upgrade it with the attachment. Any ideas on why its not working properly here's my code so far...
went = mail("".$borEmail.", ".$MAEmail."", "PreApproval Letter from ".$MAName."", "<html> <head> <style> BODY { background-color: #FFFFFF; } TD { font-size: 10pt; font-family: arial; } </style> </head> <table align='center' valign='top' border='5'> <tr><td> <table> <tr><td> <center> <img height='195' width='261' src='http://www.looktoliberty.com/Enterprise/images/liberty.gif'> </center> </td></tr> <tr><td><center><i>(888)622-8470</center></td></tr> <tr><td><center><i>www.LookToLiberty.com</center></td></tr> <tr><td><hr></td></tr> <tr> <td> ".$theDate." <br><br> Dear ".$borName.", <br><br> <b>Re: Loan Pre-Approval Notification and Conditions</b> <br><br> It is with great pride and pleasure that Liberty Mortgage Funding extends to you the PreApproval of your home loan. From the onset of your application we have enjoyed working with you to accumulate the necessary documentation to arrive to this momentous occasion whereby we are able to issue your commitment, with the following terms. <br><br> <b>Name(s):</b><br> <u>".$borName." ".$coName."</u> <br><br> <b>Secured by the property located at:</b><br> ".$propAddr."</u> <b>Loan Terms:</b><br> <u>Sales Price: $".number_format($row_PurchPA['purchasePrice'], 0, '.', ',')."</u><br> <u>Loan Amount: $".number_format(($row_loan['loanAmount'] + $row_loan['secondLoanAmount']), 0, '.', ',')."</u><br></u> ".$sellersConc." <br><br> ".$FHAVAinfo." This PreApproval is subject to certain conditions and restrictions including a requirement that you provide us with additional documentation to support the information already provided and that your financial situation remains unchanged or improves. Final approval subject to verification of documentation submitted and information obtained from the borrower as well as conformance with underwriting guidelines. Any change in this information upon verification or change in credit may invalidate this PreApproval. This letter is valid for 60 days from the date the initial credit report was obtained. <br><br> Once you have selected the property you wish to purchase, and before you sign a purchase agreement, please let us know immediately the exact payments for Property Taxes, Homeowner's Insurance and Homeowner's Association dues, and we will issue a conditional approval based on these accurate figures. <br><br> Liberty Mortgage Funding assumes we will be using our internal Title Company, Freedom Preferred Title (an affiliate of First American Title) to ensure accurate and timely closings. Freedom Preferred Title will close your home loan at a location you or the seller chooses, wherever is most convenient for all parties - including either Realtor's office, the Seller's Home or at a location of your choosing. <br><br> We understand that financing your home is one of the most important decisions you make in your lifetime. Liberty Mortgage Funding would like to make your experience as delightful as the time you will spend in your new home. Please feel free to call us if you have any questions on the terms and conditions of this approval. Thank you for your immediate attention. <br><br> Sincerely, <br><br> ".$MAName."<br> Mortgage Advisor </td> </tr> </table> </td></tr> </table>", "From: ".$MAEmail."\n". "MIME-Version: 1.0\n". "Content-type: text/html; charset=iso-8859-1". "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" .$data. "\n\n" );
fclose($file);
if($went) { echo "You have successfully sent the PreApproval letter to: ".$borEmail.""; }
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6309
38674 credits Members referred : 374
Sandwich Artist
Posts: 25
186 credits Members referred : 0
« Reply #2 on: Mar 05, 2008, 09:09:28 PM »
well i don't want to have to add anything for our email, since we've been using php mail() for a long time and its worked pretty well for us, just this one particular email that needs a generic pdf file sent along with it. I looked through some other examples around the net and managed to get mine to send the email and an attachment, but it won't open in adobe due to corrupt file and it doesn't give it the right name herer's my code
Sandwich Artist
Posts: 25
186 credits Members referred : 0
« Reply #4 on: Mar 07, 2008, 12:46:45 AM »
Well I took your advice and am trying to use phpmailer, my first attempt got the email to send and the attachment went through fine...but my email body is html and it just showed up as the html text instead of formatting it accordingly.
Here's my code
<?php
$message = "<html><head><style>BODY{ background-color: #FFFFFF;} TD {font-size: 10pt; font-family: arial; }</style></head> <table align='center' valign='top' border='5'> <tr><td> <table> <tr><td> <center> <img height='195' width='261' src='http://www.looktoliberty.com/Enterprise/images/liberty.gif'> </center> </td></tr> <tr><td><center><i>(888)622-8470</center></td></tr> <tr><td><center><i>www.LookToLiberty.com</center></td></tr> <tr><td><hr></td></tr> <tr> <td> ".$theDate." <br><br> Dear ".$borName.", <br><br> <b>Re: Loan Pre-Approval Notification and Conditions</b> <br><br> It is with great pride and pleasure that Liberty Mortgage Funding extends to you the PreApproval of your home loan. From the onset of your application we have enjoyed working with you to accumulate the necessary documentation to arrive to this momentous occasion whereby we are able to issue your commitment, with the following terms. <br><br> <b>Name(s):</b><br> <u>".$borName." ".$coName."</u> <br><br> <b>Secured by the property located at:</b><br> ".$propAddr."</u> <b>Loan Terms:</b><br> <u>Sales Price: $".number_format($row_PurchPA['purchasePrice'], 0, '.', ',')."</u><br> <u>Loan Amount: $".number_format(($row_loan['loanAmount'] + $row_loan['secondLoanAmount']), 0, '.', ',')."</u><br></u> ".$sellersConc." <br><br> ".$FHAVAinfo." This PreApproval is subject to certain conditions and restrictions including a requirement that you provide us with additional documentation to support the information already provided and that your financial situation remains unchanged or improves. Final approval subject to verification of documentation submitted and information obtained from the borrower as well as conformance with underwriting guidelines. Any change in this information upon verification or change in credit may invalidate this PreApproval. This letter is valid for 60 days from the date the initial credit report was obtained. <br><br> Once you have selected the property you wish to purchase, and before you sign a purchase agreement, please let us know immediately the exact payments for Property Taxes, Homeowner's Insurance and Homeowner's Association dues, and we will issue a conditional approval based on these accurate figures. <br><br> Liberty Mortgage Funding assumes we will be using our internal Title Company, Freedom Preferred Title (an affiliate of First American Title) to ensure accurate and timely closings. Freedom Preferred Title will close your home loan at a location you or the seller chooses, wherever is most convenient for all parties - including either Realtor's office, the Seller's Home or at a location of your choosing. <br><br> We understand that financing your home is one of the most important decisions you make in your lifetime. Liberty Mortgage Funding would like to make your experience as delightful as the time you will spend in your new home. Please feel free to call us if you have any questions on the terms and conditions of this approval. Thank you for your immediate attention. <br><br> Sincerely, <br><br> ".$MAName."<br> Mortgage Advisor </td> </tr> </table> </td></tr> </table> </html>";
// HTML body $body = $message; $mail->Body = $body; $mail->AddAddress($borEmail, $MAEmail); $mail->AddAttachment("AmendatoryClause(Letter).pdf", "AmendatoryClause(Letter).pdf"); // optional name if(!$mail->Send()) { echo "There has been a mail error sending to " . $borEmail.", ".$MAEmail . "<br>"; } else { echo 'It Sent'; }
Any ideas on why the html is coming through as plain text, at least thats what it looks like?
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6309
38674 credits Members referred : 374
It's time to use PHP5!
« Reply #5 on: Mar 07, 2008, 08:21:25 AM »
check also their manual, the methods and variables are very well documented. You need to enable this setting:
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8037
41179 credits Members referred : 3
« Reply #6 on: Mar 08, 2008, 03:41:15 PM »
Yeah Olaf's example works. If you still have problems with phpMailer (I had a few problems with utf-8 encoded messages) try swift mail. It is another great library for mail.
Yeah Olaf's example works. If you still have problems with phpMailer (I had a few problems with utf-8 encoded messages) try swift mail. It is another great library for mail.
yeah right both of them are the best php mail scripts around here, most bigger projects are using them