webspace hosting web hosting| online dating| joomla themes| website hosting| free web hosting| com domains| report abuse
Unlimited Web Hosting

Unlimited disk space/traffic/domains
1-click app installer, $9.99/month

VPS Hosting

Free Control Panel, full root access
Virtuozzo Containers, $25.00/month

Unlimited Internet Fax to Email

Unlimited faxes, no fees
dedicated phone number

Reseller Hosting

Reseller hosting services, domains,
vps, dedicated servers. Join free!

send_an_email.php

You can go back to where you came from by clicking here

send_an_email.php

TOC

<?php


function dump_file_length_header($data) {
   #
   # this function is used to build the 
   #  Content-Length: nnn
   # header where nnn is the size of the file
   # note all of our files are encoded into
   # mime or base64 so the size will be larger
   # then the orginal file size
   #
   # the file has been read into memory
   # get the size of it
   #
   $bytes=strlen($data);
   #
   # build the content-length header
   #
   $length_header="Content-Length: $bytes\r\n";
   #
   # return to the caller
   #
   return $length_header;
}
function tell_em_about_attached_file($fname,$attachment,$name) {
   #
   # if the file name is not blank
   # this function generates a message
   # telling them
   #    1) file name
   #    2) is it an attachment or not YES/NO
   #    3) the name used
   #
   $message="";
   #
   # if the name is not blank do our stuff
   #
   if ($_FILES[$fname]['name'] != '') {
     #
     # assume it isn't an attachment
     #
     $isitanattachment="NO";
     if ($attachment == 'a') {
        #
        # well gosh it IS an attachment
        #
        $isitanattachment="YES";
     }
     #
     # build the message
     #
     $pc_name=$_FILES[$fname]['name'];
     $message="$pc_name, a=$isitanattachment n='$name'\n";
   }  
   #
   # return the message to the caller
   #
   return $message;
}
function build_tr_for_file($file) {
   if ($_FILES[$file]['name'] != "" ) {
      echo "<tr><td>Filename</td><td>{$_FILES[$file]['name']}</td></tr>";
      echo "<tr><td>File type</td><td>{$_FILES[$file]['type']}</td></tr>";
      echo "<tr><td>File size</td><td>{$_FILES[$file]['size']}</td></tr>";
      echo "<tr><td>File error</td><td>{$_FILES[$file]['error']}</td></tr>";
      echo "<tr><td>File on server</td><td>{$_FILES[$file]['tmp_name']}</td></tr>";
      echo "<tr><td colspan=\"2\">&nbsp;</td></tr>";
     }
   return;
}


function get_blank_lines($count) {
   #
   # i dont know how many blank lines i need
   # before and after the file so this function
   # will let me enter between 0 and 9 which
   # one of the values will work
   #
   for($i=0;$i<10;$i++) {
      $selected="";
      if ($i == $count) {
         $selected=" selected ";
      }
      echo "<option value=\"$i\" $selected>$i</option>";
   }
   return;
}

function tell_about_file_uploaded_to_us ($file) {
   # 
   # for debugging tell them some info about
   # the file they have uploaded
   #
   # blank the message
   #
   $status_messages="";
   #
   # if the file has been uploaded get the details
   #
   if ($_FILES[$file]['name'] != "" ) {
       #
       # tell them the files name
       #      
       $status_messages.=$_FILES[$file]['name'];
       $status_messages.=" contains ";
       #
       # tell them the files size in bytes
       #  
       $status_messages.=$_FILES[$file]['size'];
       #
       # tell them where the file was uploaded to
       # which is usually a randomly made name in
       #      /tmp
       #  
       $status_messages.=" bytes is attached to this email as ";
       $status_messages.=$_FILES[$file]['tmp_name'];
       $status_messages.=" with ";
       #
       # tell them how many errors the file had as it was uploaded
       # at least that is what i think this is.
       # I dont know for sure.
       #  
       $status_messages.=$_FILES[$file]['error'];
       $status_messages.=" errors\n";
   }
   #
   # return the message to the caller
   #
   return $status_messages;
}

function setup_call_to_attach_file ($zname, $attachment, $attachmentname, $cr_before, $cr_after, $dump_flength, $dont_use_imap) {
   #
   # make the output null
   #
   $header="";
   #
   # create an array to make a copy of the file info
   #
   $filex=array();
   #
   # if the file was entered then add it to the header info
   #
   if ($_FILES[$zname]['name'] != "" ) {
      #
      # copy the file array
      #
      $filex=$_FILES[$zname];
      #
      # get the files name
      #
      $filexname=$_FILES[$zname]['name'];
      #
      # put the files data to the header
      #
      $header=attach_a_file_to_headers($filex, 
                                        $attachment, 
                                        $attachmentname,
                                        $filexname,
                                        $cr_before,
                                        $cr_after,
                                        $dump_flength,
                                        $dont_use_imap);
        }
   #
   # all done return the data to the caller
   #
   return $header;
}



function attach_a_file_to_headers($file, $attachment, $name, $filename, $cr_before, $cr_after, $dump_flength, $dont_use_imap) {
   #
   # this function will build the header records
   # that are used to attach a file to an email
   # and send the file as an attachment
   #   $file       - the file array with file informaion
   #   $attachment - is this file going to be an attachment
   #               - as opposed to a file that will be say
   #               - an image in html displayed
   #   $name       - the name of this file, not the filename
   #               - this is the name used in an <a or <img tag
   #               - like   <img src="foo">
   #               - as opposed to the files name like
   #               - resume.doc which is part of the $file array
   #
   # zero out the data we want to return
   #
   $data="";
   #
   # debug the puppy
   #
   if (0) {
      echo "attachment=$attachment<br>";
      echo "attachment name=$name<br>";
      echo "file array=$file<br>"; 
      foreach ($file as $f) {
         echo "&nbsp;&nbsp;&nbsp;$f<br>";
      }
   }
   #
   # are we supposed to attache it as an  attachment
   # as opposed to an inline file which could be used
   # as an image when we display the email as HTML
   #
   if ( $attachment != '' ) {
      $data.="Content-Disposition: attachment;\r\n";
   }
   #
   # should we add the file name?
   #
   if ($filename != '') {
      $data.="filename=\"$filename\"\r\n";
   }
   #
   # add the content-type
   #  
   $data.="Content-type: ".$file['type'];
   #
   # if we have a "name" put it after the content type
   if ($name != '' ) {
      $data.=" name=\"$name\"";
   }
   #
   # either way put a \n at the end of the content-type
   #
   $data.="\r\n";
   #
   # tell it that the text that follows is mime or base64
   # which are two ways to say the same thing
   #






   #
   # read the file into memory
   #
   $file_data=file_get_contents($file['tmp_name']);
   #
   # convert the file data into mime text or base64 text
   # 
   #
   # for useless information this is how the file is encoded
   # see this URL for more info
   #   
   #         http://www.freesoft.org/CIE/RFC/1521/7.htm
   #
   #   Value Encoding  Value Encoding  Value Encoding  Value Encoding
   #        0 A            17 R            34 i            51 z
   #        1 B            18 S            35 j            52 0
   #        2 C            19 T            36 k            53 1
   #        3 D            20 U            37 l            54 2
   #        4 E            21 V            38 m            55 3
   #        5 F            22 W            39 n            56 4
   #        6 G            23 X            40 o            57 5
   #        7 H            24 Y            41 p            58 6
   #        8 I            25 Z            42 q            59 7
   #        9 J            26 a            43 r            60 8
   #       10 K            27 b            44 s            61 9
   #       11 L            28 c            45 t            62 +
   #       12 M            29 d            46 u            63 /
   #       13 N            30 e            47 v
   #       14 O            31 f            48 w         (pad) =
   #       15 P            32 g            49 x
   #       16 Q            33 h            50 y
   #
   # do the encoding
   #


   #$dont_use_imap
   if (! function_exists('imap_binary') || $dont_use_imap == 'y') {
      #
      # imap_binary() function does not exist
      # or we are testing and want to use my function
      # use my code to convert to mime or base64
      #
      if (! function_exists('imap_binary')) {
         echo "imap_binary() function does not exist<br>";
      }
      if ($dont_use_imap == 'y') {
         #echo "who cares about imap_binary() we ain't using it<br>";
      }
      #echo "using mikes IMAP function<br>";
      #
      # convert the string to a monster string
      # which is encoded in base64 or mime format
      #
      $base64data0=base64_encode($file_data);
      #
      # split it into lines that are 60 bytes long
      #
      $base64data=chunk_split($base64data0,60);
   }
   else {
      #
      # imap_binary function exists!
      # use it
      #
      #echo "imap_binary() function EXISTS<br>";
      $base64data=imap_binary($file_data);
   }







   #
   # dump the header that tells the length of the data
   # before the base64 header
   #
   if ( $dump_flength == 'before' ) {
      $data.=dump_file_length_header($base64data);
   }
   $data.="Content-transfer-encoding: base64\r\n";
   #
   # dump the header that tells the length of the data
   # after the base64 header
   #
   if ( $dump_flength == 'after' ) {
      $data.=dump_file_length_header($base64data);
   }
   #
   # should we add extra blank lines before the file?
   #
   if ($cr_before > 0 ) {
      $extra_blank_lines=0;
      while($extra_blank_lines < $cr_before) {
         $data.="\r\n";
         $extra_blank_lines++;
      }
   }
   #echo "like this<br>Content-Type: text/plain; charset=US-ASCII; name=mud<br>";
   #
   # add the mime or base64 data to the header
   #
   $data.=$base64data;
   #
   # should we add extra blank lines after the file?
   #
   if ($cr_after > 0 ) {
      $extra_blank_lines=0;
      while($extra_blank_lines < $cr_after) {
         $data.="\r\n";
         $extra_blank_lines++;
      }
   } 
   #
   # debug and dump the data
   #
   if (0) {
      echo "header=<pre>$data\"</pre>end header<p>";
   }
   #
   # return the data
   #
   return $data;
}
?>
<html>
<?php
#
# print our ip address
#
if (0) {
   echo "IP Address=";
   echo ${REMOTE_ADDR};
   echo "<p>";
}
#
# if we are at the lycos site print
# a few blank lines at the top to
# get around their annoying headers
#
#if (${REMOTE_ADDR} == '156.42.68.5' || ${REMOTE_ADDR} == '212.78.204.20') {
if (${REMOTE_ADDR} == '212.78.204.20') {
   for ($i=0;$i<3;$i++) {
      echo "&nbsp;<p>";
   }
}


?>
I moved the notes on MIME and multipart attachment to 
<a href="#mime_notes">here</a> at the bottom of the page.
<br>
This is the 
<a href="http://miksup.100webspace.net/class/display_send_an_email.php">source code</a> for this program.
<br>
You can go back to where you came from by
clicking
<a href=" 
<?php
#echo "{$_SERVER['HTTP_REFERER']}<br>";
#echo "{$HTTP_SERVER_VARS['HTTP_REFERER']}<br>";
echo $_ENV['HTTP_REFERER'];
?>
">here</a>
<p>
<?php
#
# include this function to clean up the
# data returned from PHP forms
# those annoying forms return
#    ", ', and \
# as
#    \",  \', and \\
#
#
# since i am giving this to grey DONT
# include the function. hard code it
#
#include "clean_php_form_data.php";
function clean_php_form_data($data) {
   #
   # for some reason when you enter the characters
   #     ", ', and \
   # into a PHP form they are returned as
   #     \", \', and \\
   #
   # well this function cleans up the data
   # and removes the annoying backslashes
   #
   # oddly data is NOT returned this way in PERL
   #
   $data=preg_replace('/\\\\\'/',"'",$data);
   $data=preg_replace('/\\\\\"/','"',$data);
   $data=preg_replace('/\\\\\\\\/',"\\",$data);
   return $data;
}
#
function sum_total_errors($data, $total_errors) {
   if ($data != '' ) {
      $total_errors++;
   }
   return $total_errors;
}
function clean_up_to_lines($data) {
    #
    # remove leading and trailing spaces
    #
    $data=preg_replace("/^ */","",$data);
    $data=preg_replace("/ *\$/","",$data);
    #
    # remove extra spaces
    #
    $data=preg_replace("/  */"," ",$data);
    #
    # remove leading and trail spaces from
    #       < frog@dog.com   >
    $data=preg_replace("/ *< */","<",$data);
    $data=preg_replace("/ *> */",">",$data); 
    #
    # remove leading and trail spaces from commas that
    # seperate email addresses
    #      frog@god.com     ,   me@superman.gov
    #
    $data=preg_replace("/ *, */",",",$data);
    return $data;
}
function get_address_errors($data) {
    $errors="";
    if ($data != '' ) {
       $names=explode(",",$data);
       foreach ($names as $n) {
          #
          # remove leading and trailing spaces
          #
          $n=preg_replace("/^ */","",$n);
          $n=preg_replace("/ *\$/","",$n);
          #
          # if you have
          #        tom jones <you@email.com>
          # we have to validate the stuff enclosed in <>
          # as the email address and ignore the other stuff
          # this code should do that
          #
          $nn=$n;
          if (preg_match("/<.*>/",$nn)) {
             $nn=preg_replace("/^.*</","",$nn);
             $nn=preg_replace("/>.*\$/","",$nn);  
          }
          #
          # now validate the email address
          # if the email address contains spaces
          # it is invalid
          #
          if (preg_match("/ /",$nn)) {
             if ($errors == '' ) {
                $errors=$n;
             }
             else {
                $errors.=" $n";
             }
          }
          else {
             #
             # if the email address is not in the form
             #     something@somewhere.xxx
             # it is invalid
             #
             if (! preg_match("/[^@]+@[^@]+\.[^@]+/",$nn)) {
                if ($errors == '' ) {
                   $errors=$n;
                }
                else {
                   $errors.=" $n";
                }
             }
             else {
                #
                # and it cant end or begin with
                # these letters
                # nor can it have @....@ in it
                # nor can it have .. or 2 dots next to each other
                #
                $nonos="\.@";
                if (preg_match("/^[$nonos]/",$nn)  || 
                    preg_match("/[$nonos]\$/",$nn) || 
                    preg_match("/\.\./",$nn) || 
                    preg_match("/@.*@/",$nn)) {
                   #
                   # we have either
                   #    illegal begining or ending characters
                   #    multiple @ signs
                   #
                   if ($errors == '' ) {
                      $errors=$n;
                   }
                   else {
                      $errors.=" $n";
                   }
                }
             }
          }
       }
    }
    #
    # if email addresses have stuff like
    #        tom & bob <thoseguyes@email.com>
    # convert it so it is displayable
    #
    $errors=htmlentities($errors);
    #
    # make it red and tell them it is an error
    if ($errors != '' ) {
    $errors="<span style=\"background=#ff0000\">ERROR $errors</span>";
    }
    return $errors;
}

   #
   # set the default values for this program
   #
   $total_errors=0;
   $size=80;
   $rows=10;
   #
   # the size of attachment names
   # used like
   #           <img src="attachment name">
   #
   $anamesize=10;
   #
   # grab the data the user typed into the HTML form
   #

   #
   # use this to figure out the first time we are called
   # so we can initialize stuff
   #
   $hidden_post_variable=$_POST['hidden_post_variable'];



   $from=$_POST['from'];
   $to=$_POST['to'];
   $cc=$_POST['cc'];
   $bcc=$_POST['bcc'];
   $rto=$_POST['rto'];
   $text=$_POST['text'];
   $cr_before=$_POST['cr_before'];
   $cr_after=$_POST['cr_after'];
   $subject=$_POST['subject'];
   $how_to_attach=$_POST['how_to_attach'];
   $send_as_html=$_POST['send_as_html'];
   $dump_header_in_debug_window=$_POST['dump_header_in_debug_window'];
   $dont_use_imap=$_POST['dont_use_imap'];
   $put_debug_info_in_email=$_POST['put_debug_info_in_email'];




   $dump_flength=$_POST['dump_flength'];
   #echo "\$dump_flength='$dump_flength'<br>";



   #
   # if first time set the date to current time
   #
   if ($hidden_post_variable == '' ) {
      #
      # get unix time ie: base January 1 1970 00:00:00 GMT
      #
      $ztime=time();
      #
      # convert to Phoenix time
      #
      $ztime-=(60*60*9);
      #
      # 1st time use date and time in Phoenix Arizona
      # the -9000 i think it says we are 9 hours
      # before London time.
      #
      $zdate=date("D, d M Y H:i:s -0900", $ztime);
      $zdate.=" (MST)";
      #
      # also set the flag to dump the 
      # debug info into the body of the email
      #
      $put_debug_info_in_email='y';
   }
   else {
      #
      # 2nd time use date they entered on form
      #
      $zdate=$_POST['zdate'];
   }

   $attachment1=$_POST['attachment1'];
   $attachmentname1=$_POST['attachmentname1'];
   $attachment2=$_POST['attachment2'];
   $attachmentname2=$_POST['attachmentname2'];
   $attachment3=$_POST['attachment3'];
   $attachmentname3=$_POST['attachmentname3'];
   $attachmentname2=$_POST['attachmentname2'];
   $attachment4=$_POST['attachment4'];
   $attachmentname4=$_POST['attachmentname4'];
   $attachment5=$_POST['attachment5'];
   $attachmentname5=$_POST['attachmentname5'];
   $attachment6=$_POST['attachment6'];
   $attachmentname6=$_POST['attachmentname6'];

   #
   # clean up the data returned from the form
   # ', ", and \ 
   # are returned as 
   # \', \" and \\
   #
   $text=clean_php_form_data($text);
   $from=clean_php_form_data($from);
   $to=clean_php_form_data($to);
   $cc=clean_php_form_data($cc);
   $bcc=clean_php_form_data($bcc);
   $rto=clean_php_form_data($rto);
   $subject=clean_php_form_data($subject);
   #
   # verify all the FROM: email addresses are valid
   #
   $from=clean_up_to_lines($from);
   $from_errors=get_address_errors($from);
   $total_errors=sum_total_errors($from_errors, $total_errors);
   #
   # verify all the TO: email addresses are valie
   #
   $to=clean_up_to_lines($to);
   $to_errors=get_address_errors($to);
   $total_errors=sum_total_errors($to_errors, $total_errors);
   #
   # a to field is required,
   # if other data was entered
   #
   if ( $from != '' || $cc != '' || $bcc != '' || $text != '' || $subject != '' ) {
      if ($to == '' ) {
         $total_errors++;
         $to_errors.=" a TO address is required";
      }
   }
   else {
      $total_errors=-1;
   }
   #
   # verify all the CC: email addresses are valid
   #
   $cc=clean_up_to_lines($cc);
   $cc_errors=get_address_errors($cc);
   $total_errors=sum_total_errors($cc_errors, $total_errors);
   #
   # verify all the BCC: email addresses are valid
   #
   $bcc=clean_up_to_lines($bcc);
   $bcc_errors=get_address_errors($bcc);
   $total_errors=sum_total_errors($bcc_errors, $total_errors);
   #
   # verify all the Reply To: email addresses are valid
   #
   $rto=clean_up_to_lines($rto);
   $rto_errors=get_address_errors($rto);
   $total_errors=sum_total_errors($rto_errors, $total_errors);
   #
   # if errors dont send the stinking email
   #
   if ($total_errors > 0 ) {
      echo "ERROR(s) E-MAIL NOT SENT!  total errors=$total_errors<br>";
   }

?>
<table style="background-color:#dddddd">
<tr valign="top">
<td>
<!-- form action="send_an_email.php" method="post" -->
<!-- make it a miltipart/form so we can upload files -->
<form action="send_an_email.php"  
      method="post" 
      enctype="multipart/form-data"> 
<input type="submit" name=submit value="Send">



     <input type="checkbox" name="dump_header_in_debug_window"  value="y"
     <?php if ($dump_header_in_debug_window == 'y'  ){echo "checked"; } ?>>
     <a href="#dump_headers">dump headers</a>



     <a href="#dump_length">dump length</a>
     <input type="radio" name="dump_flength"  value="after"
     <?php if ($dump_flength == 'after' || $dump_flength == '' ) {echo "checked"; } ?> > After
     <input type="radio" name="dump_flength"  value="before"
     <?php if ($dump_flength == 'before' ) {echo "checked"; } ?> > Before
     <input type="radio" name="dump_flength"  value="never"
     <?php if ($dump_flength == 'never') {echo "checked"; } ?> > Don't


     &nbsp;&nbsp;&nbsp; <a href="#use_base64_not_imap">use base64 not imap</a>
     <input type="checkbox" name="dont_use_imap"  value="y"
     <?php if ($dont_use_imap == 'y'  ){echo "checked"; } ?>>




<table>
<tr>
   <td align="right">From:</td>
   <td align="left"><input type="text" name="from"  
       <?php echo " size=\"$size\" value=\"$from\""; ?> >
       <?php echo "$from_errors"; ?>
   </td>
</tr>
<tr>
   <td align="right">To:</td>
   <td align="left"><input type="text" name="to"  
       <?php echo " size=\"$size\" value=\"$to\""; ?> >
       <?php echo "$to_errors"; ?>
   </td>
</tr>
<tr>
   <td align="right">CC:</td>
   <td align="left"><input type="text" name="cc"  
       <?php echo " size=\"$size\" value=\"$cc\""; ?> >
       <?php echo "$cc_errors"; ?>
   </td>
</tr>
<tr>
   <td align="right">BCC:</td>
   <td align="left"><input type="text" name="bcc"  
       <?php echo " size=\"$size\" value=\"$bcc\""; ?> >
       <?php echo "$bcc_errors"; ?>
   </td>
</tr>

<tr>
   <td align="right">Reply To:</td>
   <td align="left"><input type="text" name="rto"  
       <?php echo " size=\"$size\" value=\"$rto\""; ?> >
       <?php echo "$rto_errors"; ?>
   </td>
</tr>



<tr>
   <td align="right">
      <a href="#the_date_info">Date</a> :)
   </td>
   <td align="left"><input type="text" name="zdate"  
       <?php echo " size=\"$size\" value=\"$zdate\""; ?> >
   </td>
</tr>


<tr>
   <td align="right">Subject:</td>
   <td align="left"><input type="text" name="subject"  
       <?php echo " size=\"$size\" value=\"$subject\""; ?> >
   </td>
</tr>
<tr>
   <td align="right">&nbsp;</td>
   <td align="left">
        Send as TEXT
        <input type="radio" name="send_as_html"  value="text"
       <?php if ($send_as_html == 'text' || $send_as_html == '' ) {echo "checked"; } ?> >,
       <a href="#html_text">HTML</a>
        <input type="radio" name="send_as_html"  value="html"
       <?php if ($send_as_html == 'html' ) { echo "checked";}       ?> >



       &nbsp;&nbsp;&nbsp;<a href="#put_debug_info_in_e-mail">Put debug info in E-mail</a>
     <input type="checkbox" name="put_debug_info_in_email"  value="y"
     <?php if ($put_debug_info_in_email == 'y'  ){echo "checked"; } ?>>





   </td>
</tr>
<tr>
   <td align="right">&nbsp;</td>
   <td align="left">
        <input type="radio" name="how_to_attach"  value="before"
       <?php if ($how_to_attach == 'before'  ){echo "checked"; } ?>>
       <s>Attach <span style="background-color:pink;">BEFORE</span> screws up HTML</s>
       <a href="#notes_on_before_after"><sup>1</sup></a>
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="#before_file">\n before file</a>
                    <select name="cr_before">
                       <?php get_blank_lines($cr_before); ?>
                    </select>
<br>
       <input type="radio" name="how_to_attach"  value="after"
       <?php if ($how_to_attach == 'after' || $send_as_html == '') {echo "checked"; } ?> >
       Attach file <span style="background-color:pink;">
       after</span> HTML in header data section
       <a href="#notes_on_before_after"><sup>1</sup></a>
        &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; 
        <a href="#after_file">\n after file</a> &nbsp;&nbsp;
                    <select name="cr_after">
                       <?php get_blank_lines($cr_after); ?>
                    </select>
<br>
       <!-- take your choice! disabled or readonly will do     -->
       <!-- i lied disabled works much better                  -->
       <input disabled type="radio" name="how_to_attach"  value="body">
       <!-- input readonly type="radio" name="how_to_attach"  value="body" -->
       <s>Attach file to <span style="background-color:pink;">end of body</span>
       as opposed to the headers</s>
       <a href="#notes_on_before_after"><sup>1</sup></a>
   </td>
</tr>
<tr>
   <td align="right">&nbsp;</td>
   <td align="left">
        <table border=0>
        <tr>
        <td>
        <table border="1">
           <tr>
               <td>File Name</td>
               <td>
                   <a href="#as_attachment">as Attachment</a>
                   <br>vs INLINE
               </td>
               <td>
                  <a href="#inline_name">name</a>
                  <br>for INLINE
               </td>
           </tr>
           <tr>
              <td>
                 <input type="file" name="file_to_upload">
              </td>
              <td>
                 <input type="checkbox" name="attachment1"  value="a"
                 <?php if ($attachment1 == 'a'  ){echo "checked"; } ?>>
              </td>
              <td>
                 <input type="text" name="attachmentname1"  
                 <?php echo " size=\"$anamesize\" value=\"$attachmentname1\""; ?> >
              </td>
           </tr>


           <tr>
              <td>
                 <input type="file" name="file_to_upload2">
              </td>
              <td>
                 <input type="checkbox" name="attachment2"  value="a"
                 <?php if ($attachment2 == 'a'  ){echo "checked"; } ?>>
              </td>
              <td>
                 <input type="text" name="attachmentname2"  
                 <?php echo " size=\"$anamesize\" value=\"$attachmentname2\""; ?> >
              </td>
           </tr>

           <tr>
              <td>
                 <input type="file" name="file_to_upload3">
              </td>
              <td>
                 <input type="checkbox" name="attachment3"  value="a"
                 <?php if ($attachment3 == 'a'  ){echo "checked"; } ?>>
              </td>
              <td>
                 <input type="text" name="attachmentname3"  
                 <?php echo " size=\"$anamesize\" value=\"$attachmentname3\""; ?> >
              </td>
           </tr>

           <tr>
              <td>
                 <input type="file" name="file_to_upload4">
              </td>
              <td>
                 <input type="checkbox" name="attachment4"  value="a"
                 <?php if ($attachment4 == 'a'  ){echo "checked"; } ?>>
              </td>
              <td>
                 <input type="text" name="attachmentname4"  
                 <?php echo " size=\"$anamesize\" value=\"$attachmentname4\""; ?> >
              </td>
           </tr>



           <tr>
              <td>
                 <input type="file" name="file_to_upload5">
              </td>
              <td>
                 <input type="checkbox" name="attachment5"  value="a"
                 <?php if ($attachment5 == 'a'  ){echo "checked"; } ?>>
              </td>
              <td>
                 <input type="text" name="attachmentname5"  
                 <?php echo " size=\"$anamesize\" value=\"$attachmentname5\""; ?> >
              </td>
           </tr>
           <tr>
              <td>
                 <input type="file" name="file_to_upload6">
              </td>
              <td>
                 <input type="checkbox" name="attachment6"  value="a"
                 <?php if ($attachment6 == 'a'  ){echo "checked"; } ?>>
              </td>
              <td>
                 <input type="text" name="attachmentname6"  
                 <?php echo " size=\"$anamesize\" value=\"$attachmentname6\""; ?> >
              </td>
           </tr>

         </table>
         </td>
         <td valign="top">

              <!--
              <table border=1>
                 <tr>
                  <td>extra \n<br>before file</td>
                  <td>extra \n<br>after file</td>
                 </tr>
                 <tr>
                 <td>
                    <select name="cr_before">
                       <?php get_blank_lines($cr_before); ?>
                    </select>
                 </td>
                 <td>
                    <select name="cr_after">
                       <?php get_blank_lines($cr_after); ?>
                    </select>
                 </td>
                 </tr>
              </table>
              -->



         </td>
         </tr>
         </table>
   </td>
</tr>
<tr>
   <td colspan="2">
       <textarea name="text" 
       <?php echo "cols=\"$size\" rows=\"$rows\" "; ?>><?php echo "$text"; ?></textarea>  
   </td>
</tr>
</table>
<p>
<input type="hidden" name="hidden_post_variable" value="hidden post data">
<input type="reset" name=reset value="RESET">
</form>
</td>
<td style="background-color:#ffff00">
<h2>Debug Window</h2>
<?php
  #
  # dont send any email
  # we have errors
  #
  if ($total_errors != 0 ) {
      
  }
  else {
     #echo "sending email!!!!! Default from:<br>";
     #
     # play with some of the php.ini values
     # and see if we can get the mail to be sent 
     #
     #$ini_value=ini_set('sendmail_from',$from);
     #$ini_value=ini_set('SMTP','on');
     #$ini_value=ini_set('SMTP','ON');

     # i did this as a wild *ass guess
     # and it doesn't work at all
     # so never let it execute
     #
     if (0) {
        #
        # if we are supposed to attach the
        # file to the body do it here.
        # i suspect this wont work
        # because the existing email software
        # will think it is text that is part
        # of the body but I could be wrong
        #
        if ( $how_to_attach == 'body') {
           if ($_FILES['file_to_upload']['name'] != "" ) {
              echo "attaching file to BODY instead of headers<br>";
              #
              # set the length of the attached file
              #
              $text.="\r\n";
              $text.="Content-Length: ";
              $text.=$_FILES['file_to_upload']['size'];
              $text.="\r\n";
              #
              # tell it the type of the attached file
              #
              $text.="Content-type: ";
              $text.=$_FILES['file_to_upload']['type'];
              $text.="\r\n";
              #
              # add the data for the attached file
              # for some reason i think we may have
              # to convert the data to mime format
              # but i could be wrong
              #
              $text.=file_get_contents($_FILES['file_to_upload']['tmp_name']);
           }
        }
     }
     #
     # send mail with DEFAULT from:
     # which at greys site is
     #   anonymous@ hosting2.fastq.com
     #
     # this is the default on my server
     # which doesnt even send the mail
     #   me@localhost.com
     #
     # we know this works so stop sending the stinking email
     #
     if (0) {
        #
        # this works so stop sending the email
        # each time i test new stuff
        # 
        $rc=mail($to,$subject,$text);
     }
     #
     # modify the DEFAULT from to this $from
     # and send the email again
     #
     # again this works so stop sending the
     # email each time i test new stuff
     #
     if (0) {
        $ini_value=ini_set('sendmail_from',$from);
        echo "sending email!!!!! modified default from: $from<br>";
        $rc=mail($to,$subject,$text);
     }
     #
     # now build a header record to use as the from:
     # and send the email with it
     #
     #
     # save $text and later restore it
     #
     $oldtext=$text;
     $status_messages="";
     #
     # for debugging tell them if we generated a
     #     content-length 
     # header and if we did where we generated it
     #
     if ($dump_flength == 'before') {
       $status_messages.="Content-Length:xxx is BEFORE base64 header \n";
     }
     if ($dump_flength == 'after') {
       $status_messages.="Content-Length:xxx is AFTER base64 header \n";
     }
     if ($dump_flength == 'never') {
       $status_messages.="Content-Length:xxx NOT used\n";
     }
     #
     # for debugging tell them how many blank lines
     # we printed before and after the file
     #
     $status_messages.="$cr_before blank lines placed BEFORE file\n";
     $status_messages.="$cr_after blank lines placed AFTER file\n";
     #
     # tell them about the files they have uploaded
     # what the file name is, how it is attached and the use name
     #
     $status_messages.=tell_em_about_attached_file('file_to_upload',
                                                   $attachment1,
                                                   $attachmentname1);
     $status_messages.=tell_em_about_attached_file('file_to_upload2',
                                                   $attachment2,
                                                   $attachmentname2);
     $status_messages.=tell_em_about_attached_file('file_to_upload3',
                                                   $attachment3,
                                                   $attachmentname3);
     $status_messages.=tell_em_about_attached_file('file_to_upload4',
                                                   $attachment4,
                                                   $attachmentname4);
     $status_messages.=tell_em_about_attached_file('file_to_upload5',
                                                   $attachment5,
                                                   $attachmentname5);
     $status_messages.=tell_em_about_attached_file('file_to_upload6',
                                                   $attachment6,
                                                   $attachmentname6);
     #
     # for debugging tell them if the file was
     # attached before or after the HTML header
     #
     if ($how_to_attach == 'before') {
       $status_messages.="File attached before HTML\n";
     }
     if ($how_to_attach == 'after') {
       $status_messages.="File attached after HTML\n";
     }
     #
     # some PHP sites dont have the function
     #   imap_binary()
     # so this code is to tell us about that
     # and let us test the function either way
     #


     if ($dont_use_imap == 'y') {
       $status_messages.="Dont use imap_binary flag set to Y\n";
     }
     else {
       $status_messages.="Dont use imap_binary flag NOT set\n";
     }
     if (function_exists('imap_binary')) {
       $status_messages.="imap_binary() EXISTS\n";
     }
     else {
       $status_messages.="imap_binary() DOESNT exist\n";
     }





     #
     # never do this! the body stuff was 
     # a wild *ss guess that didnt work
     # 
     if (0) {
        if ($how_to_attach == 'body') {
          $status_messages.="File attached to body as opposed to headers\n";
        } 
     }
     #
     # for debugging for each file uploaded tell them
     #        filename, file size, unix filename, errors
     # this message is listed in the body of the email
     #
     $stinking_files_uploaded=0;
     $status_messagesx=tell_about_file_uploaded_to_us ('file_to_upload');
     if ($status_messagesx != '' ) {
        $stinking_files_uploaded++;
        $status_messages.=$status_messagesx;
     }
     $status_messagesx=tell_about_file_uploaded_to_us ('file_to_upload2');
     if ($status_messagesx != '' ) {
        $stinking_files_uploaded++;
        $status_messages.=$status_messagesx;
     }
     $status_messagesx=tell_about_file_uploaded_to_us ('file_to_upload3');
     if ($status_messagesx != '' ) {
        $stinking_files_uploaded++;
        $status_messages.=$status_messagesx;
     }
     $status_messagesx=tell_about_file_uploaded_to_us ('file_to_upload4');
     if ($status_messagesx != '' ) {
        $stinking_files_uploaded++;
        $status_messages.=$status_messagesx;
     }
     $status_messagesx=tell_about_file_uploaded_to_us ('file_to_upload5');
     if ($status_messagesx != '' ) {
        $stinking_files_uploaded++;
        $status_messages.=$status_messagesx;
     }
     $status_messagesx=tell_about_file_uploaded_to_us ('file_to_upload6');
     if ($status_messagesx != '' ) {
        $stinking_files_uploaded++;
        $status_messages.=$status_messagesx;
     }
     #
     # if no files were uploaded tell them
     #
     if ($stinking_files_uploaded == 0 ) {
        $status_messages.="No files attached to this email\n";
     }
     if ($send_as_html == 'html' ) {
       $status_messages.="Sending as HTML\n";
       $status_messages=preg_replace("/\n/","<br>\n",$status_messages);
     }
     else {
       $status_messages.="NOT sending as HTML\n";
     }


     #
     # if this variable is set to a y then
     # put the debug information into the
     # body of the email.
     # this way I can turn off the debugging
     # and use it to send homeland security 
     # messages to cartoonists like benson :)
     #
     if ($put_debug_info_in_email == 'y') {
        $text=$status_messages.$text;
     }
     $header="";
     #
     # build the from: header
     #
     if ($from != "" ) {
        $header.="From: $from\r\n";
        #echo "Sending with headers<blockquote><pre>";
        #echo "$header";
        #echo "</pre></blockquote>";  
     }
     #
     # build the CC: header
     #
     if ($cc != "" ) {
        $header.="CC: $cc\r\n";
        #echo "Sending with headers<blockquote><pre>";
        #echo "$header";
        #echo "</pre></blockquote>";
     }
     #
     # build the BCC: header
     #
     if ($bcc != "" ) {
        $header.="BCC: $bcc\r\n";
        #echo "Sending with headers<blockquote><pre>";
        #echo "$header";
        #echo "</pre></blockquote>";  
     }
     #
     # build the Reply To: header
     #
     if ($rto != "" ) {
        #
        # "reply to:" doesnt work
        # try using
        # "reply-to:"
        #
        if (0) {
           $header.="Reply To: $rto\r\n";
        }
        else {
           $header.="Reply-To: $rto\r\n";
        }
        #echo "Sending with headers<blockquote><pre>";
        #echo "$header";
        #echo "</pre></blockquote>";  
     }
     #
     # build the Date: header
     #
     if ($zdate != "" ) {
        $header.="Date: $zdate\r\n";
        #echo "Sending with headers<blockquote><pre>";
        #echo "$header";
        #echo "</pre></blockquote>";  
     }





     #we may have to flip the order we add the HTML and attached files
     # which is why i put the
     # if ($how_to_attach == "after" ) {
     # }
     # and
     # if ($how_to_attach == "before" ) {
     # }
     # logic
     #
     # i probably have to give the file i attach a name
     # look at my manuals for that. I remember they gave
     # a jpg file they used in an email in one example
     # a name
     #
     #
     # here we will first add the HTML header
     # then we will attach the file and its header
     # 
     # i am guessing the existing php mail software
     # will pull the first html header and use it
     # for the text in the body of the message
     # but i could be wrong on that
     #
     if ($how_to_attach == "after" ) {
        #
        # if we are sending it as HTML 
        # build the html header before the FILES
        #
        if ($send_as_html == 'html' ) {
           $header.="Content-type: text/html\r\n";
        }
        #
        # add the file they uploaded as an attachment to the e-mail
        #
        #echo "<p>make sure the header has been attached AFTER this<p>";
        #
        # add each file entered to the header information
        #
        $header.=setup_call_to_attach_file ('file_to_upload', $attachment1, $attachmentname1, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 
        $header.=setup_call_to_attach_file ('file_to_upload2', $attachment2, $attachmentname2, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 
        $header.=setup_call_to_attach_file ('file_to_upload3', $attachment3, $attachmentname3, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 
        $header.=setup_call_to_attach_file ('file_to_upload4', $attachment4, $attachmentname4, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 
        $header.=setup_call_to_attach_file ('file_to_upload5', $attachment5, $attachmentname5, $cr_before, $cr_after, $dump_flength, $dont_use_imap);
        $header.=setup_call_to_attach_file ('file_to_upload6', $attachment6, $attachmentname6, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 



 
        

     }
     if ($how_to_attach == "before" ) {
        #
        # add the file they uploaded as an attachment to the e-mail
        #
        #echo "<p>make sure the header has been attached BEFORE this<p>";



        #
        # add each file entered to the header information
        #
        $header.=setup_call_to_attach_file ('file_to_upload', $attachment1, $attachmentname1, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 
        $header.=setup_call_to_attach_file ('file_to_upload2', $attachment2, $attachmentname2, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 
        $header.=setup_call_to_attach_file ('file_to_upload3', $attachment3, $attachmentname3, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 
        $header.=setup_call_to_attach_file ('file_to_upload4', $attachment4, $attachmentname4, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 
        $header.=setup_call_to_attach_file ('file_to_upload5', $attachment5, $attachmentname5, $cr_before, $cr_after, $dump_flength, $dont_use_imap);
        $header.=setup_call_to_attach_file ('file_to_upload6', $attachment6, $attachmentname6, $cr_before, $cr_after, $dump_flength, $dont_use_imap); 





        #if ($_FILES['file_to_upload']['name'] != "" ) {
        #   #
        #   # attach the first selected file to the header
        #   #
        #   $file1=array();
        #   $file1=$_FILES['file_to_upload'];
        #   $file1name=$_FILES['file_to_upload']['name'];
        #   $header.=attach_a_file_to_headers($file1, 
        #                                     $attachment1, 
        #                                     $attachmentname1,
        #                                     $file1name,
        #                                     $cr_before,
        #                                     $cr_after);
        #}
        #
        # if we are sending it as HTML 
        # build the html header after the FILES
        #
        if ($send_as_html == 'html' ) {
           $header.="Content-type: text/html\r\n";
        }
     }
     #
     # dump the headers ?
     #
     if ($dump_header_in_debug_window == 'y') {
        echo "<b>dumping headers</b>";
        echo "<pre>";
        echo $header;
        echo "</pre>";
     }
     #
     # only send the email ONCE and send it here
     # before I was sending it after I built
     # each and every header
     #
     echo "SENDING the E-MAIL now!<br>";
     $rc=mail($to,$subject,$text,$header);
     #
     # we have sent the email but
     # print some information in the debug window
     # about how we sent the email
     #
     echo "<table border=1>";
     $x=htmlentities($to);
     echo "<tr><td align=\"right\">To:</td><td>$x &nbsp;</td></tr>";
     $x=htmlentities($cc);
     echo "<tr><td align=\"right\">CC:</td><td>$x &nbsp;</td></tr>";
     $x=htmlentities($bcc);
     echo "<tr><td align=\"right\">BCC:</td><td>$x &nbsp;</td></tr>";
     $x=htmlentities($rto);
     echo "<tr><td align=\"right\">Reply To:</td><td>$x &nbsp;</td></tr>";
     $x=htmlentities($from);
     echo "<tr><td align=\"right\">From:</td><td>$x &nbsp;</td></tr>";



     #
     # list the data about each of the files
     # that were uploaded in table format
     # for debugging
     #
     build_tr_for_file('file_to_upload');
     build_tr_for_file('file_to_upload2');
     build_tr_for_file('file_to_upload3');
     build_tr_for_file('file_to_upload4');
     build_tr_for_file('file_to_upload5');
     build_tr_for_file('file_to_upload6');

     #if ($_FILES['file_to_upload']['name'] != "" ) {
     #   echo "<tr><td>Filename</td><td>{$_FILES['file_to_upload']['name']}</td></tr>";
     #   echo "<tr><td>File type</td><td>{$_FILES['file_to_upload']['type']}</td></tr>";
     #   echo "<tr><td>File size</td><td>{$_FILES['file_to_upload']['size']}</td></tr>";
     #   echo "<tr><td>File error</td><td>{$_FILES['file_to_upload']['error']}</td></tr>";
     #   echo "<tr><td>File on server</td><td>{$_FILES['file_to_upload']['tmp_name']}</td></tr>";
     #}


     $x=htmlentities($subject);
     echo "<tr><td align=\"right\">Subject:</td><td>$x &nbsp;</td></tr>";
     $x=$text;
     #
     # if they are sending it as text
     # convert the krud in the message
     # to html stuff so we can view
     # it in netscape
     # ie 
     #     > becomes &gt;
     #     < becomes &lt;
     #     .....
     #
     if ( $send_as_html == 'text' ) {
        $x=htmlentities($text);
        #
        # make the spaces display correctly with &nbsp;
        #
        $x=preg_replace("/ /","&nbsp;",$x);
        #
        # make line breaks display correctly with <br>
        #
        $x=preg_replace("/\n/","<br>",$x);
     }
     echo "<tr><td colspan=2>$x&nbsp;</td></tr>";
     echo "<tr><td align=\"right\">RC</td><td>$rc&nbsp;</td></tr>";

     if ($rc != 1 ) {
        echo "<tr><td colspan=\"2\">Hmmm... Something has changed. The rc used to be set to one</td></tr>";
     }
     echo "</table>";
  }   
?>
</td>
</tr>
</table>
<a name="php.ini.stuff">
<h2>PHP.INI stuff</h2>
These are the values I want:
<blockquote>
<table border=1 style="background-color:#00ffff">
<tr><td>SMTP </td><td> "localhost"</td><td> PHP_INI_ALL</td></tr>  
<tr><td>smtp_port</td><td> "25"</td><td> PHP_INI_ALL</td></tr>
<tr><td>sendmail_from</td><td> NULL</td><td> PHP_INI_ALL</td></tr>   
<tr><td>sendmail_path</td><td> "/usr/sbin/sendmail -t -i"</td><td> PHP_INI_SYSTEM</td></tr>   
</table>
</blockquote>
And these are the actual values that PHP returns
<blockquote>
<table border=1 style="background-color:#00ffff">
<?php
$foo=array('smtp_port','SMTP','sendmail_from','sendmail_path');
foreach ($foo as $x) {
   $ini_value=ini_get($x);
   echo "<tr><td>$x</td><td>$ini_value</td><td>ini_get('$x')</td></tr>";
}
?>
</table>
</blockquote>
Lets try to reset one of them using this code
<blockquote>
$ini_value=ini_set('sendmail_from','root@unix.com');
</blockquote>
and see what happens!
Here are the results and it looks like the change worked!
<blockquote>
<table border=1 style="background-color:#00ffff">
<?php
$ini_value=ini_set('sendmail_from','root@unix.com');
$foo=array('smtp_port','SMTP','sendmail_from','sendmail_path');
foreach ($foo as $x) {
   $ini_value=ini_get($x);
   echo "<tr><td>$x</td><td>$ini_value</td><td>ini_get('$x')</td></tr>";
}
?>
</table>
</blockquote>

<table width="100%" border="0">
<tr>
<td width="50%">
<a name="dump_headers">
<h3>Dump Headers</h3>
When you check the "dump headers" box
I write a whole bunch of debug information
to the right of the form in a box with
a yellow background.
<p>
You will see all the header and data
information I am passing to the
program that sends the e-mail.
<a name="dump_length">
<h3>dump length</h3>
When you click on the dump length button
for each file uploaded I will generate
a header record that has the length of the
uploaded file in bytes. That is the length
of the file after it has been converted to
mime. That header record looks like this
<blockquote>
Content-Length: 9672 
</blockquote>
And I am not sure how the software uses this.
At this point in time I am trying to avoid
writting the code using "multi-part forms"
because that gets a little messy and
I am hoping by allowing the length I
won't need to use "multi-part forms"
<p>
When I first heard the term 
"multi-part forms"
I thought the data was cut into
chunks and sent as multi-parts.
Well that may or may not be true
but it has absolutely nothing to
do with "multi-part forms".
<p>
A "multi-part form" is when you send several files
in one data stream and use unique string ID to
delimit the files.
<p>
And example is send three files using the string id
<blockquote>
frozen_frogs_drink_beer_and_smoke_cigarettes
</blockquote>
Would look like this:
<blockquote>
--frozen_frogs_drink_beer_and_smoke_cigarettes<br>
Data for file #1<br>
--frozen_frogs_drink_beer_and_smoke_cigarettes<br>
Data for file #2<br>
--frozen_frogs_drink_beer_and_smoke_cigarettes<br>
Data for file #3<br>
--frozen_frogs_drink_beer_and_smoke_cigarettes
</blockquote>
Only it seems that it is a little bit more
complex then that!




<a name="use_base64_not_imap">
<h3>use base64 not imap</h3>
The orginal code I wrote uses a function
<blockquote>
imap_binary()
</blockquote>
to convert the data from text to base64 or mime format.
Some versions of PHP don't have that functions
so the orginal program blows up when loaded on those
systems.
<p>
To get around that problem I check to see if the
function imap_binary() exists and if it doesn't
I use this code 
<blockquote>
$base64data0=base64_encode($file_data);<br>
$base64data=chunk_split($base64data0,60);
</blockquote>
to convert the data to mime or base64 format, 
then I split the data into 60 byte blocks.
<p>
So that I can test this code on a system that
has imap_binary() I put this check box so
I can force it to use the above code instead
of imap_binary().
<a name="the_date_info">
<h3>Date:</h3>
You can use this field to set the date the email was sent.
If you leave it blank I use the default time,
whatever that is.
You can put anything you want in it like:
<blockquote>
Yesterday<br>
Tomorrow<br>
December 25, 2029<br>
July 4, 1776
</blockquote>
The first time the program is run I will 
put the current Phoenix time in the field
with something like this
<blockquote>
Mon, 24 Dec 2007 11:37:20 -0900 (MST)
</blockquote>
In this case
<blockquote>
Mon - is the day of the week or Monday<br>
24 - is the day of the month or Dec 24<br>
Dec - is the month or December<br>
2007 - is the year<br>
11:37:20 - is the current time<br>
-0900 (MST) - says that Phoenix time is 9 hours before London time<br>
(MST) - says that Phoenix time is Mountain Standard Time
</blockquote>




<a name="put_debug_info_in_e-mail">
<h3>Put debug info in E-mail</h3>
OK it is Christmas time and all the cartoonists
are making fun of the homeland security thugs
and how they are going to shake down Santa Claus.
<p>
So for fun I sent a couple of cartoonists 
e-mails telling them how they are in trouble
with the TSA thugs for thinking they have
First Amendment rights.
<p>
This switch tells the software not to put
any of the debug information into the body
of the mail, so the e-mail will look like
a message from the government thugs in
the homeland security department. 
<p>
And just so the homeland security thugs
won't jail me for life, I used the non-existant
Department of Homeland IN-Security as the e-mail 
address
<a name="notes_on_before_after">
<h3>Notes on Before and After<sup>1</sup></h3>
<h4>No files attached</h4>
When you DON'T attach a file and send HTML
it seems to always work irregardless of
if you click on the before or after buttons.
<h4>One or more files attached</h4>
When one or more files are attached and you send HTML
it always works with the after button checked.
<p>
When one or more files are attached and you send HTML
the HTML is always screwed up when the before button checked.
<h4>Attach file to end of body</h4>
When the button that says
<blockquote>
Attach file to end of body 
</blockquote>
was clicked on and you attached files
and sent HTML it always seemed to  
screw stuff up.
<p>
That is why i disabled the button.
<h4>Attaching files still doesn't work</h4>
I still have to figure out how to attach files
so they are NOT in the body of the text,
but are attached as a file which you can click on
and down load.
<p>
I think that must be done using a multi-part form
header. But I still have to play with it.
<p>
The way the current code works is I just send the
file off using something like this
<blockquote>
<tt>
filename="resume.doc"<br>
Content-type: application/msword<br>
Content-transfer-encoding: base64<br>
Content-Length: 90298<br>
0 or more blank lines<br>
0M8R4KGxGu mime or base64 data AAAAAAAAAAAPgADAP7<br>
0 or more blank lines
</tt>
</blockquote>
<a name="before_file">
<h3>\n Before File</h3>
This is the number of blank lines
to print before dumping the file.
It is just for debugging.
I think I can get by with out
any blanks lines.
But there is a remote chance that
one blank line may be needed.
<a name="after_file">
<h3>\n After File</h3>
This is the number of blank lines
to print after dumping the file.
It is just for debugging.
I think I can get by with out
any blanks lines.
But there is a remote chance that
one blank line may be needed.
<a name="as_attachment">
<h3>As Attachment</h3>
I beleive there are two types of attachments you can have
when you send a file with an e-mail.
<p>
The first one is an attachment that the user
can download to his computer.
<p>
That is what you get when you click on one of
these buttons.
When you do this i generate the header record
<blockquote>
<nobr>Content-Disposition: attachment;</nobr>
</blockquote>
The 2nd type of attachment is for use when you
have the email displayed as HTML.
<p>
You could have an image attached to display in
the HTML, or another HTML web page for them
to jump to when they click on an A tag.
And this type of attachment is used for that.
<a name="inline_name">
<h3>Inline Name</h3>
In this case the NAME field is used to identify
the name of the image or other html to jump to.
<p>
In this case I add the name to the following header record
<blockquote>
<nobr>Content-type: image/pjpeg name="frogs"</nobr>
</blockquote>
In the above case I suspect that the name "frogs"
would be used in either an
<blockquote>
&lt;img src="frogs"&gt;
</blockquote>
tag or if the attached thing was html it would
be used in an A tag like this
<blockquote>
&lt;a href="frogs"&gt;&nbsp;&nbsp;&nbsp;&lt;/a&gt; 
</blockquote>
<h3>Uploaded file name</h3>
For each file you upload I generate a header record
that looks like this with the name of the uploaded
file. The name is the filename of the file
on the computer which it was uploaded from
<blockquote>
filename="222.jpg"
</blockquote>
I am not sure if this file name can be used
in the html tags.
Nor am I sure of what this file name can
be used for anywhere.
<h3>Uploaded file name on the remote server</h3>
When the file gets to the server it is usually
saved in 
<blockquote>
/tmp/xxx
</blockquote>
where xxx is a randomly generated file name
<a name="html_text">
<h3>TEXT HTML Radio buttons</h3>
If you click on the HTML radio button in
the two button radio set which is
TEXT and HTML
I will generate this header records
which says to send the e-mail as HTML
<blockquote>
Content-type: text/html
</blockquote>
I am not sure how the mail function uses it.
</td>
<td width="50%">
&nbsp;
</td>
</tr>
</table>
<h2>MIME notes</h2>
<a name="mime_notes">
<?php
#
# include my notes on mime and mulitpart attachments
#
include "notes_mime_attachment.php";
?>