
February 26th, 2005, 03:14 PM
|
|
|
|
Join Date: Apr 2007
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Mail() W/ Attachments
Here is the tutorial script now I was just testing this on my server because I like to take things apart and see how they work, but this one doesn't work?
It mail is neverreceived???
Any Suggestions...
Thanks,
php Code:
Original
- php Code |
|
|
|
<?php ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <table> <tr> <td>To:</td> <td><input type="text" name="to" size="40"/></td> </tr> <tr> <td>From:</td> <td><input type="text" name="from" size="40" /></td> </tr> <tr> <td>Subject:</td> <td><input type="text" name="re" size="40" /></td> </tr> <tr> <td>Message:</td> <td><textarea cols="30" rows="5" name="comments"></textarea></td> </tr> <tr> <td>Attachment:</td> <td><input type="file" name="att" size="26" /></td> </tr> <td colspan="2"><input type="submit" value="Send Form" /></td> </tr> </table> </form> <?php }else{ $fp = fopen( $att_name, "r"); $file = fread( $fp, $att_size ); /* Encode The Data For Transition using base64_encode(); And get a 32-character hexadecimal number */ /* Define the main message headers */ $hdr = "From:$fromrn"; $hdr .= "MIME-Version: 1.0rn"; $hdr .= "Content-Type: multipart/mixed; "; $hdr .= "boundary=$numrn"; $hdr .= "--$numrn"; /* Define message section */ $hdr .= "Content-Type: text/plainrn"; $hdr .= "Content-Transfer-Encoding: 8bitrnn"; $hdr .= "$commentsrn"; $hdr .= "--$numn"; /* Define the attachment section */ $hdr .= "Content-Type: $att_type; "; $hdr .= "name="$att_name"rn"; $hdr .= "Content-Transfer-Encoding: base64rn"; $hdr .= "Content-Disposition: attachment; "; $hdr .= "filename="$att_name"rnn"; $hdr .= "$filern"; $hdr .= "--$num--"; /* Send the email */ mail( '$to', '$re', '$comments', '$hdr'); /* Close the attachment */ } ?>
|