Attaching a XML file to a PHP Email

Discussion in 'PHP' started by MiguelS, Dec 2, 2008.

  1. #1
    Sorry if this code is long....but I am a beginner working on an online application for our non-profit beagle rescue. I have this form that will do three things.
    1. send the information as a test to certain foster.
    2. send a xml text format to my wife to import the data into a PDF file

    3. (what i am trying to work on) send an attachment (xml) email

    I was able to get the file to write into the application.xml file now...but I want to send it to my wife now as an attachment.

    I did all this from reading and auto generated forms and then modifying them myself. I just cannot understand the attachment section. Thus my first post and asking for help.

    -Miguel

    <?php
    
    $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
    
    session_start();
    if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) { 
    
    // Checkbox handling
    $field_12_opts = $_POST['field_12'][0];
    $field_12A_opts = $_POST['field_12A'][0];
    
    // Checkbox handling
    $field_13_opts = $_POST['field_13'][0];
    $field_13A_opts = $_POST['field_13A'][0];
    $field_13B_opts = $_POST['field_13B'][0];
    
    // read the list of emails from the file.
    $email_list = file("elist.txt");
    
    // count how many emails there are.
    $total_emails = count($email_list);
    
    // go through the list and trim off the newline character.
    for ($counter=0; $counter<$total_emails; $counter++) {
    $email_list[$counter] = trim($email_list[$counter]);
    }
    
    // implode the list into a single variable, put commas in, apply as $to value.
    $to = implode(",",$email_list);
    
    mail($to,"Online Beagle Application for " . $_POST['field_26'] . " by " . $_POST['field_1'] . " ","Form data:
    
    Application date: " . date("F jS, Y")  . "
    
    HOUSEHOLD INFORMATION:
    Pet interested in: " . $_POST['field_26'] . " 
    Name: " . $_POST['field_1'] . " 
    Address: " . $_POST['field_2'] . " 
    City: " . $_POST['field_3'] . " 
    State: " . $_POST['field_4'] . " 
    Zip Code: " . $_POST['field_5'] . " 
    Home Phone: " . $_POST['field_6'] . " 
    Other Phone: " . $_POST['field_7'] . " 
    e-Mail: " . $_POST['field_8'] . " 
    Others in Home (Name/Age): " . $_POST['field_9'] . " , " . $_POST['field_9A'] . " 
    Others in Home (Name/Age): " . $_POST['field_9B'] . " , " . $_POST['field_9C'] . " 
    Others in Home (Name/Age): " . $_POST['field_9D'] . " , " . $_POST['field_9E'] . " 
    What other pets currently reside in your home?: " . $_POST['field_10'] . "
    Are they spayed/neutered?: " . $_POST['field_11'] . "
    What other pets currently reside in your home?: " . $_POST['field_10A'] . "
    Are they spayed/neutered?: " . $_POST['field_11A'] . "
    What other pets currently reside in your home?: " . $_POST['field_10B'] . "
    Are they spayed/neutered?: " . $_POST['field_11B'] . "
    
    
    DESIRED PET: 
    What do you prefer?: $field_12_opts , $field_12A_opts
    What size do you prefer?: $field_13_opts , $field_13A_opts , $field_13B_opts
    Preferred age: " . $_POST['field_73'] . "
    What breed are you looking for?: " . $_POST['field_14'] . " 
    What is your knowledge of this breed?: " . $_POST['field_15'] . " 
    Is everyone in your household in favor of adopting a pet?: " . $_POST['field_16'] . " 
    Is this pet going to be a gift?: " . $_POST['field_17'] . " 
    
    HOUSING SITUATION:
    Housing?: " . $_POST['field_18'] . " 
    Housing Type?: " . $_POST['field_19'] . " 
    Landlord Name (if applicable)?: " . $_POST['field_20'] . " 
    Landlord Phone (if applicable)?: " . $_POST['field_21'] . " 
    Can NCARF contact your Landlord?: " . $_POST['field_22'] . " 
    Have you informed your Landlord that you are adopting a pet?: " . $_POST['field_23'] . " 
    Is the residence listed above the same location of where the new pet will be living?: " . $_POST['field_24'] . " 
    
    GENERAL QUESTIONS:
    Do you understand that NCARF must spay/neuter all pets prior to adoption?: " . $_POST['field_25'] . " 
    Are you ready to make a lifetime commitment to your pet?: " . $_POST['field_27'] . " 
    Who will be the primary caretaker of the pet?: " . $_POST['field_28'] . " 
    Why are you getting a pet?: " . $_POST['field_29'] . " 
    Have you ever given a pet away?: " . $_POST['field_30'] . " 
    What were the circumstances?: " . $_POST['field_31'] . " 
    Are you willing to provide your new dog with the cost of care that includes food, veterinary care, licensing, microchipping, vaccinations, etc?: " . $_POST['field_32'] . " 
    If your pet has a special need or requires emergency medical treatment (costs can quickly exceed $500) can you provide adequate financial care?: " . $_POST['field_33'] . " 
    What type of identification will you pet wear?: " . $_POST['field_34'] . " 
    What is your household level of activity? : " . $_POST['field_35'] . " 
    Where will the pet live?: " . $_POST['field_36'] . " 
    Percent of the time pet will be indoors?: " . $_POST['field_37'] . " 
    Percent of the time pet will be outdoors?: " . $_POST['field_38'] . " 
    Where will the dog sleep?: " . $_POST['field_39'] . " 
    How many hours are you away from home each day?: " . $_POST['field_40'] . " 
    Where will the pet be kept when it is alone?: " . $_POST['field_41'] . " 
    What will you do with your pet when you travel?: " . $_POST['field_42'] . " 
    Do you have dog doors?: " . $_POST['field_43'] . " 
    Do you have an enclosed yard?: " . $_POST['field_44'] . " 
    How tall are your fences?: " . $_POST['field_45'] . " 
    Fence Type?: " . $_POST['field_46'] . " 
    Do your fences need repair?: " . $_POST['field_47'] . " 
    If yes, please explain: " . $_POST['field_48'] . " 
    Will you chain your dog in the yard?: " . $_POST['field_49'] . " 
    If yes, under what circumstances?: " . $_POST['field_50'] . " 
    Most dogs require regular exercise, who will exercise your pet?: " . $_POST['field_51'] . " 
    What type of exercise will the pet get?: " . $_POST['field_52'] . " 
    Are you ready to give your pet daily care, companionship, and exercise, and not only when it is convenient for you?: " . $_POST['field_53'] . " 
    Do you have a swimming pool?: " . $_POST['field_54'] . " 
    Would you agree to have your property checked to ensure it is secure for a pet?: " . $_POST['field_55'] . " 
    
    TRAINING:
    Who will be responsible for training your new pet?: " . $_POST['field_56'] . " 
    Have you ever attended a dog or puppy obedience class or a behavioral class?: " . $_POST['field_57'] . " 
    Do you plan to attend dog obedience classes with your new pet?: " . $_POST['field_58'] . " 
    If no, explain:: " . $_POST['field_59'] . " 
    How do you plan to socialize your new pet?: " . $_POST['field_60'] . " 
    What will you do if your pet develops behavioral problems?: " . $_POST['field_61'] . " 
    How will you handle inappropriate urination or defecation in the house?: " . $_POST['field_62'] . " 
    
    PERSONAL STATEMENT:
    In the space provided below, please let us know why you would make a great adoptive parent:: " . $_POST['field_63'] . " 
    
    QUESITIONS:
    What questions can we answer for you?: " . $_POST['field_64'] . " 
    
    FAMILY VET INFORMATION:
    Veterinarian Name: " . $_POST['field_65'] . " 
    Veterinarian Telephone: " . $_POST['field_66'] . " 
    Veterinarian Address: " . $_POST['field_67'] . " 
    Veterinarian City: " . $_POST['field_68'] . " 
    Veterinarian State: " . $_POST['field_69'] . " 
    Veterinarian Zip Code: " . $_POST['field_70'] . " 
    Can NCARF contact your Veterinarian?: " . $_POST['field_71'] . " 
    
    APPLICATION AGREEMENT: " . $_POST['field_72'] . " 
    ");
    
    // This mail section is to send the xml data as text 
    mail($to,"Online Beagle Application for " . $_POST['field_26'] . " by " . $_POST['field_1'] . " ","
    <form1>
    <TextField1>" . $_POST['field_26'] . "</TextField1>
    <TextField2>" . $_POST['field_1'] . "</TextField2> 
    <TextField3>" . $_POST['field_2'] . "</TextField3> 
    <TextField4>" . $_POST['field_3'] . "</TextField4> 
    <TextField6>" . $_POST['field_5'] . "</TextField6> 
    <TextField7>" . $_POST['field_6'] . "</TextField7> 
    <TextField8>" . $_POST['field_7'] . "</TextField8> 
    <TextField9>" . $_POST['field_8'] . "</TextField9> 
    <TextField5>C" . $_POST['field_4'] . "</TextField5> 
    <TextField10>" . $_POST['field_9'] . "</TextField10> 
    <TextField10A>" . $_POST['field_9A'] . "</TextField10A> 
    <TextField11>" . $_POST['field_9B'] . "</TextField11> 
    <TextField11A>" . $_POST['field_9C'] . "</TextField11A> 
    <TextField12>" . $_POST['field_9D'] . "</TextField12> 
    <TextField12A>" . $_POST['field_9E'] . "</TextField12A> 
    <RadioButtonList1>" . $_POST['field_10'] . "</RadioButtonList1> 
    <RadioButtonList2>" . $_POST['field_11'] . "</RadioButtonList2> 
    <RadioButtonList3>" . $_POST['field_10A'] . "</RadioButtonList3> 
    <RadioButtonList4>" . $_POST['field_11A'] . "</RadioButtonList4> 
    <RadioButtonList5>" . $_POST['field_10B'] . "</RadioButtonList5> 
    <RadioButtonLis6>" . $_POST['field_11B'] . "</RadioButtonLis6> 
    <TextField13>" . $_POST['field_73'] . "</TextField13> 
    <TextField14>" . $_POST['field_14'] . "</TextField14> 
    <TextField15>" . $_POST['field_15'] . "</TextField15> 
    <RadioButtonList9>" . $_POST['field_16'] . "</RadioButtonList9> 
    <RadioButtonList10>" . $_POST['field_17'] . "</RadioButtonList10> 
    <RadioButtonList11>" . $_POST['field_18'] . "</RadioButtonList11> 
    <RadioButtonList12>" . $_POST['field_19'] . "</RadioButtonList12> 
    <TextField16>" . $_POST['field_20'] . "</TextField16> 
    <TextField17>" . $_POST['field_21'] . "</TextField17> 
    <RadioButtonList13>" . $_POST['field_22'] . "</RadioButtonList13> 
    <RadioButtonList14>" . $_POST['field_23'] . "</RadioButtonList14> 
    <RadioButtonList15>" . $_POST['field_24'] . "</RadioButtonList15> 
    <CheckBox1>$field_12_opts</CheckBox1> 
    <CheckBox1>$field_12A_opts</CheckBox1> 
    <CheckBox2>$field_13_opts</CheckBox2> 
    <CheckBox2>$field_13A_opts</CheckBox2> 
    <CheckBox2>$field_13B_opts</CheckBox2> 
    <RadioButtonList16>" . $_POST['field_25'] . "</RadioButtonList16> 
    <RadioButtonList17>" . $_POST['field_27'] . "</RadioButtonList17> 
    <TextField18>" . $_POST['field_28'] . "</TextField18> 
    <TextField19>" . $_POST['field_29'] . "</TextField19> 
    <RadioButtonList18>" . $_POST['field_30'] . "</RadioButtonList18> 
    <TextField20>" . $_POST['field_31'] . "</TextField20> 
    <RadioButtonList19>" . $_POST['field_32'] . "</RadioButtonList19> 
    <RadioButtonList20>" . $_POST['field_33'] . "</RadioButtonList20> 
    <TextField21>" . $_POST['field_34'] . "</TextField21> 
    <RadioButtonList21>" . $_POST['field_35'] . "</RadioButtonList21> 
    <RadioButtonList22>" . $_POST['field_36'] . "</RadioButtonList22> 
    <TextField43>" . $_POST['field_37'] . "</TextField43> 
    <TextField44>" . $_POST['field_38'] . "</TextField44> 
    <TextField22>" . $_POST['field_39'] . "</TextField22> 
    <TextField23>" . $_POST['field_40'] . "</TextField23> 
    <TextField24>" . $_POST['field_41'] . "</TextField24> 
    <TextField25>" . $_POST['field_42'] . "</TextField25> 
    <RadioButtonList23>" . $_POST['field_43'] . "</RadioButtonList23> 
    <RadioButtonList24>" . $_POST['field_44'] . "</RadioButtonList24> 
    <DropDownList1>" . $_POST['field_45'] . "</DropDownList1> 
    <RadioButtonList25>" . $_POST['field_46'] . "</RadioButtonList25> 
    <RadioButtonList26>" . $_POST['field_47'] . "</RadioButtonList26> 
    <TextField26>" . $_POST['field_48'] . "</TextField26> 
    <TextField27>" . $_POST['field_50'] . "</TextField27> 
    <RadioButtonList27>" . $_POST['field_49'] . "</RadioButtonList27> 
    <TextField28>" . $_POST['field_51'] . "</TextField28> 
    <TextField29>" . $_POST['field_52'] . "</TextField29> 
    <RadioButtonList28>" . $_POST['field_53'] . "</RadioButtonList28> 
    <RadioButtonList29>" . $_POST['field_54'] . "</RadioButtonList29> 
    <RadioButtonList30>" . $_POST['field_55'] . "</RadioButtonList30> 
    <TextField30>" . $_POST['field_56'] . "</TextField30> 
    <TextField31>" . $_POST['field_59'] . "</TextField31> 
    <RadioButtonList31>" . $_POST['field_58'] . "</RadioButtonList31> 
    <TextField32>" . $_POST['field_60'] . "</TextField32> 
    <TextField33>" . $_POST['field_61'] . "</TextField33> 
    <TextField34>" . $_POST['field_62'] . "</TextField34> 
    <TextField35>" . $_POST['field_65'] . "</TextField35> 
    <TextField36>" . $_POST['field_67'] . "</TextField36> 
    <TextField37>" . $_POST['field_68'] . "</TextField37> 
    <TextField39>" . $_POST['field_70'] . "</TextField39> 
    <TextField40>" . $_POST['field_66'] . "</TextField40> 
    <TextField38>" . $_POST['field_69'] . "</TextField38> 
    <RadioButtonList32>" . $_POST['field_71'] . "</RadioButtonList32> 
    <RadioButtonList33>" . $_POST['field_72'] . "</RadioButtonList33> 
    <TextField41>" . $_POST['field_63'] . "</TextField41> 
    <TextField42>" . $_POST['field_64'] . "</TextField42> 
    </form1>
    ");
    
    // This mail section is to store the xml data 
    $fileLine = "<form1>
    <TextField1>" . $_POST['field_26'] . "</TextField1>
    <TextField2>" . $_POST['field_1'] . "</TextField2> 
    <TextField3>" . $_POST['field_2'] . "</TextField3> 
    <TextField4>" . $_POST['field_3'] . "</TextField4> 
    <TextField6>" . $_POST['field_5'] . "</TextField6> 
    <TextField7>" . $_POST['field_6'] . "</TextField7> 
    <TextField8>" . $_POST['field_7'] . "</TextField8> 
    <TextField9>" . $_POST['field_8'] . "</TextField9> 
    <TextField5>C" . $_POST['field_4'] . "</TextField5> 
    <TextField10>" . $_POST['field_9'] . "</TextField10> 
    <TextField10A>" . $_POST['field_9A'] . "</TextField10A> 
    <TextField11>" . $_POST['field_9B'] . "</TextField11> 
    <TextField11A>" . $_POST['field_9C'] . "</TextField11A> 
    <TextField12>" . $_POST['field_9D'] . "</TextField12> 
    <TextField12A>" . $_POST['field_9E'] . "</TextField12A> 
    <RadioButtonList1>" . $_POST['field_10'] . "</RadioButtonList1> 
    <RadioButtonList2>" . $_POST['field_11'] . "</RadioButtonList2> 
    <RadioButtonList3>" . $_POST['field_10A'] . "</RadioButtonList3> 
    <RadioButtonList4>" . $_POST['field_11A'] . "</RadioButtonList4> 
    <RadioButtonList5>" . $_POST['field_10B'] . "</RadioButtonList5> 
    <RadioButtonLis6>" . $_POST['field_11B'] . "</RadioButtonLis6> 
    <TextField13>" . $_POST['field_73'] . "</TextField13> 
    <TextField14>" . $_POST['field_14'] . "</TextField14> 
    <TextField15>" . $_POST['field_15'] . "</TextField15> 
    <RadioButtonList9>" . $_POST['field_16'] . "</RadioButtonList9> 
    <RadioButtonList10>" . $_POST['field_17'] . "</RadioButtonList10> 
    <RadioButtonList11>" . $_POST['field_18'] . "</RadioButtonList11> 
    <RadioButtonList12>" . $_POST['field_19'] . "</RadioButtonList12> 
    <TextField16>" . $_POST['field_20'] . "</TextField16> 
    <TextField17>" . $_POST['field_21'] . "</TextField17> 
    <RadioButtonList13>" . $_POST['field_22'] . "</RadioButtonList13> 
    <RadioButtonList14>" . $_POST['field_23'] . "</RadioButtonList14> 
    <RadioButtonList15>" . $_POST['field_24'] . "</RadioButtonList15> 
    <CheckBox1>$field_12_opts</CheckBox1> 
    <CheckBox1>$field_12A_opts</CheckBox1> 
    <CheckBox2>$field_13_opts</CheckBox2> 
    <CheckBox2>$field_13A_opts</CheckBox2> 
    <CheckBox2>$field_13B_opts</CheckBox2> 
    <RadioButtonList16>" . $_POST['field_25'] . "</RadioButtonList16> 
    <RadioButtonList17>" . $_POST['field_27'] . "</RadioButtonList17> 
    <TextField18>" . $_POST['field_28'] . "</TextField18> 
    <TextField19>" . $_POST['field_29'] . "</TextField19> 
    <RadioButtonList18>" . $_POST['field_30'] . "</RadioButtonList18> 
    <TextField20>" . $_POST['field_31'] . "</TextField20> 
    <RadioButtonList19>" . $_POST['field_32'] . "</RadioButtonList19> 
    <RadioButtonList20>" . $_POST['field_33'] . "</RadioButtonList20> 
    <TextField21>" . $_POST['field_34'] . "</TextField21> 
    <RadioButtonList21>" . $_POST['field_35'] . "</RadioButtonList21> 
    <RadioButtonList22>" . $_POST['field_36'] . "</RadioButtonList22> 
    <TextField43>" . $_POST['field_37'] . "</TextField43> 
    <TextField44>" . $_POST['field_38'] . "</TextField44> 
    <TextField22>" . $_POST['field_39'] . "</TextField22> 
    <TextField23>" . $_POST['field_40'] . "</TextField23> 
    <TextField24>" . $_POST['field_41'] . "</TextField24> 
    <TextField25>" . $_POST['field_42'] . "</TextField25> 
    <RadioButtonList23>" . $_POST['field_43'] . "</RadioButtonList23> 
    <RadioButtonList24>" . $_POST['field_44'] . "</RadioButtonList24> 
    <DropDownList1>" . $_POST['field_45'] . "</DropDownList1> 
    <RadioButtonList25>" . $_POST['field_46'] . "</RadioButtonList25> 
    <RadioButtonList26>" . $_POST['field_47'] . "</RadioButtonList26> 
    <TextField26>" . $_POST['field_48'] . "</TextField26> 
    <TextField27>" . $_POST['field_50'] . "</TextField27> 
    <RadioButtonList27>" . $_POST['field_49'] . "</RadioButtonList27> 
    <TextField28>" . $_POST['field_51'] . "</TextField28> 
    <TextField29>" . $_POST['field_52'] . "</TextField29> 
    <RadioButtonList28>" . $_POST['field_53'] . "</RadioButtonList28> 
    <RadioButtonList29>" . $_POST['field_54'] . "</RadioButtonList29> 
    <RadioButtonList30>" . $_POST['field_55'] . "</RadioButtonList30> 
    <TextField30>" . $_POST['field_56'] . "</TextField30> 
    <TextField31>" . $_POST['field_59'] . "</TextField31> 
    <RadioButtonList31>" . $_POST['field_58'] . "</RadioButtonList31> 
    <TextField32>" . $_POST['field_60'] . "</TextField32> 
    <TextField33>" . $_POST['field_61'] . "</TextField33> 
    <TextField34>" . $_POST['field_62'] . "</TextField34> 
    <TextField35>" . $_POST['field_65'] . "</TextField35> 
    <TextField36>" . $_POST['field_67'] . "</TextField36> 
    <TextField37>" . $_POST['field_68'] . "</TextField37> 
    <TextField39>" . $_POST['field_70'] . "</TextField39> 
    <TextField40>" . $_POST['field_66'] . "</TextField40> 
    <TextField38>" . $_POST['field_69'] . "</TextField38> 
    <RadioButtonList32>" . $_POST['field_71'] . "</RadioButtonList32> 
    <RadioButtonList33>" . $_POST['field_72'] . "</RadioButtonList33> 
    <TextField41>" . $_POST['field_63'] . "</TextField41> 
    <TextField42>" . $_POST['field_64'] . "</TextField42> 
    </form1>
    ";
    
    $filename = 'application.xml';
    if (is_writable($filename)) {
    
    			    if (!$handle = fopen($filename, 'w+'))
    			    {
    			         echo "Cannot open file ($filename)";
    			         exit;
    			    }
    			    if (fwrite($handle, $fileLine) === FALSE) {
    			        echo "Cannot write to file ($filename)";
    			        exit;
    			    }
    
    			    fclose($handle);
    
    			} else {
    			    echo "The file  is not writable";
    			}
    
    include("confirm.html");
    }
    else {
    echo "Invalid Captcha String. \r\n";
    echo "\nIf you close this window you will lose your application data, please use the back button on your browser or ALT+Left to re-enter code.";
    }
    
    ?>
    Code (markup):
     
    MiguelS, Dec 2, 2008 IP
  2. MiguelS

    MiguelS Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Test version:

    The fillled out form creates teh file applicaiton.xml. NowI want to mail that out as well.


    <?php
    
    $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
    
    //define the receiver of the email 
    $to = 'example@yahoo.com'; 
    //define the subject of the email 
    $subject = 'Test email with attachment'; 
    //create a boundary string. It must be unique 
    //so we use the MD5 algorithm to generate a random hash 
    $random_hash = md5(date('r', time())); 
    //define the headers we want passed. Note that they are separated with \r\n 
    $headers = "From: example@yahoo.com\r\nReply-To: example@yahoo.com"; 
    //add boundary string and mime type specification 
    $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; 
    
    $fileLine = "First Name: " . $_POST['field_1'] . " 
    State: " . $_POST['field_2'] . " 
    Email: " . $_POST['field_3'] . " 
    Phone: " . $_POST['field_4'] . " 
    Alternate Phone: " . $_POST['field_5'] . " 
    Best Time To Call: " . $_POST['field_6'] . " 
    What is the status of your loan?: " . $_POST['field_7'] . " 
    What would you like help with?: " . $_POST['field_8'] . " 
    What is your current loan balance?: " . $_POST['field_9'] . " 
    What is your current property value?: " . $_POST['field_10'] . " 
    Last Name: " . $_POST['field_11'] . " 
    Address: " . $_POST['field_12'] . " 
    City: " . $_POST['field_13'] . " 
    Zip Code: " . $_POST['field_14'] . " 
    
    ";
    $filename = 'application.xml';
    if (is_writable($filename)) {
    
    			    if (!$handle = fopen($filename, 'w+'))
    			    {
    			         echo "Cannot open file ($filename)";
    			         exit;
    			    }
    			    if (fwrite($handle, $fileLine) === FALSE) {
    			        echo "Cannot write to file ($filename)";
    			        exit;
    			    }
    
    			    fclose($handle);
    
    			} else {
    			    echo "The file  is not writable";
    			}
    
    
    //read the atachment file contents into a string,
    //encode it with MIME base64,
    //and split it into smaller chunks
    $attachment = chunk_split(base64_encode(file_get_contents('application.xml'))); 
    
    //define the body of the message. 
    ob_start(); //Turn on output buffering 
    ?> 
    --PHP-mixed-<?php echo $random_hash; ?>  
    Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" 
    
    --PHP-alt-<?php echo $random_hash; ?>  
    Content-Type: text/plain; charset="iso-8859-1" 
    Content-Transfer-Encoding: 7bit
    
    Hello World!!! 
    This is simple text email message. 
    
    --PHP-alt-<?php echo $random_hash; ?>  
    Content-Type: text/html; charset="iso-8859-1" 
    Content-Transfer-Encoding: 7bit
    
    <h2>Hello World!</h2> 
    <p>This is something with <b>HTML</b> formatting.</p> 
    
    --PHP-alt-<?php echo $random_hash; ?>-- 
    
    --PHP-mixed-<?php echo $random_hash; ?>  
    Content-Type: application/xhtml+xml; name="application.xml"  
    Content-Transfer-Encoding: base64  
    Content-Disposition: attachment  
    
    <?php echo $attachment; ?> 
    --PHP-mixed-<?php echo $random_hash; ?>-- 
    
    <?php 
    //copy current buffer contents into $message variable and delete current output buffer 
    $message = ob_get_clean(); 
    //send the email 
    $mail_sent = @mail( $to, $subject, $message, $headers ); 
    //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
    echo $mail_sent ? "Mail sent" : "Mail failed"; 
    ?> 
    <?php
    
    include("confirm.html");
    
    ?>
    Code (markup):
     
    MiguelS, Dec 2, 2008 IP
  3. MiguelS

    MiguelS Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I got it to work!

    Form is filled out.
    Data is entered into a file on my server.
    Grab file from server and attached as an email and sent.
     
    MiguelS, Dec 3, 2008 IP