function mail_attachment2 ($from , $to, $subject, $message, $attachment,$filetype,$filename,$filetype2,$filename2){ $fileatt = $attachment; // Path to the file
$fileatt_type = $filetype; // File Type $start= strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1; //$fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the attachment $fileatt_name = $filename; //$fileatt_name = "testEmail.txt";
$email_from = $from; // Who the email is from $email_subject = $subject; // The Subject of the email $email_txt = $message; // Message that the email has in it
$email_to = $to; // Who the email is to
$headers = "From: ".$email_from;
$file = fopen($fileatt,"rb");
$si=filesize($fileatt); $data = fread($file,$si); fclose($file); //$msg_txt="\n\nMail created using free code from 4word systems : http://4wordsystems.com";
/********************************************** First File ********************************************/
$fileatt = $attachment; // Path to the file $fileatt_type = $filetype; // File Type $fileatt_name = $filename; // Filename that will be used for the file as the attachment //$fileatt_name = "sendEmailMultipleAttachments.rtf"; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file);
/********************************************** Second File ********************************************/
$fileatt = $attachment; // Path to the file $fileatt_type = $filetype2; // File Type $fileatt_name = $filename2; // Filename that will be used for the file as the attachment
if($ok) { echo "And sended sucessfully"; //unlink($fileatt); } else { die("Sorry but the email could not be sent. Please go back and try again!"); } }//end function multiple attachments
if(isset($_FILES['userfile']['name'])){ $from="diep@chariot.net.au"; $to="diep@chariot.net.au"; $subject="send email with attachments"; $message="testing attachment";
//print_r($_FILES);
mail_attachment2($from,$to,$subject,$message,$_FILES['userfile']['tmp_name'],$_FILES['userfile']['type'],$_FILES['userfile']['name'],$_FILES['userfile2']['type'],$_FILES['userfile2']['name']); }//end if
?>
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 5799
46391 credits Members referred : 3