php email an attachment

Discussion in 'PHP' started by mthacker, Mar 5, 2008.

  1. #1
    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...

    <?php

    $fileatt_name = 'AmendatoryClause(Letter).pdf';
    $fileatt_type = 'application/pdf';
    $fileatt = 'AmendatoryClause(Letter).pdf';
    $file = fopen($fileatt,'rb');
    $data = fread($file,filesize($fileatt));
    $data = chunk_split(base64_encode($data));

    // echo $data;


    $borEmail = 'mattthacker@looktoliberty.com';

    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."";
    }
     
    mthacker, Mar 5, 2008 IP
  2. 00johnny

    00johnny Peon

    Messages:
    149
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if you look on the php doc sites help on the mail function
    mail() <--click to go there
    PHP:
    under the comments section I think there are a few peopl who've made mail functions to handle attachments...
     
    00johnny, Mar 5, 2008 IP