Thanks ErnieAlex, I had to remove the first forward slash to get the script to work. A big thank you goes to you and Astonecipher!
On to my next php problem now
my final code for all was/is:-
[php]<?php
if (isset($_POST[‘submit’]))
{
$file_name = $_POST[‘file_name’];
$doc_email = $_POST[‘doc_email’];
$doc_message = $_POST[‘doc_message’];
$file_type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file_name);
$username = $_POST[‘username’];
$company = $_POST[‘company’];
//define the receiver of the email
$to = $_POST[‘doc_email’];
$subject = “$username from $company Sent you a file”;
//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: [email protected]\r\nReply-To: [email protected]”;
//add boundary string and mime type specification
$headers .= “\r\nContent-Type: multipart/mixed; boundary=“PHP-mixed-”.$random_hash.”"";
//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(“uploads/” . $_POST[“file_name”] )));
//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 there,
<?php echo $username; ?> from <?php echo $company; ?> sent you a file.
<?php echo $username; ?> wrote:-
<?php echo $doc_message; ?>
–PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset=“iso-8859-1”
Content-Transfer-Encoding: 7bit
Hi there,
<?php echo $username; ?> from <?php echo $company; ?> sent you a file.
<?php echo $username; ?> wrote:-
<?php echo $doc_message; ?>
For further information about this email or for any questions you may have regarding XX please contact [email protected]
–PHP-alt-<?php echo $random_hash; ?>–
–PHP-mixed-<?php echo $random_hash; ?>
Content-Type: application/<?php echo $filetype; ?>; name="<?php echo $file_name; ?>"
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]