PHP mailto () and attachement
Posted: Mon May 05, 2008 7:11 am
Hi, i have this code to send emails using mail function
and upload file code
and the uploader.php
i am having a hard time combining those two, something like a webmail function like attaching files then send it out to recepient... is there such a work around on this? Thanks so much! 
Code: Select all
<?PHP
$hostname = "hostname";
$email1 = $custemail;
$email2 = "email@email.com";
$subject = "subject";
$datafooterhtml ="footer";
$datafootertxt ="data";
# -=-=-=- MIME BOUNDARY
$mime_boundary = "----project name----".md5(time());
# -=-=-=- MAIL HEADERS
$to = "$email1".","."$email2";
$headers = "headers";
# -=-=-=- TEXT EMAIL PART
$message .= "Content-Type: text/plain; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= "Message \n";
$message .= "\n\n";
# -=-=-=- FINAL BOUNDARY
$message .= "--$mime_boundary--\n\n";
# -=-=-=- SEND MAIL
ini_set("smtp", "mail.server.com");
ini_set ("sendmail_from","email@email.com");
$mail_sent = @mail( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
and upload file code
Code: Select all
<form enctype="multipart/form-data" action="uploader.php?account=<?PHP print $accountname; ?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<span class="texttable">Choose a file to upload:</span>
<input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
Code: Select all
<?PHP
$account = $_GET["accountname"];
$target_path = "uploads/";
$target_path = $target_path . $account . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "<script language='JavaScript' >
alert('File has been uploaded');
location = 'data.php';
</script>";
} else{
echo " <script language='JavaScript' >
alert('There was an error uploading the file...')
location = 'data2.php'
</script>";
}
?>