|
|
|
|
|
|
| |
|
<?php
// Path to the file
$fileatt = "";
// File Type
$fileatt_type = "application/octet-stream";
// Filename that will be used for the file as the attachment
$fileatt_name = "";
// Who the email is from
$email_from = "";
// The Subject of the email
$email_subject = "";
// Message that the email has in it
$email_txt = "";
// Who the email is too
$email_to = "";
$headers = "From: ".$email_from;
// check if your file is exist in your folder or not
if (file_exists($fileatt)) {
echo "The file $fileatt exists";
}else{
echo "The file $fileatt does not exist";
}
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
$ok = @mail($email_to, $email_subject, $email_message, $headers);
if($ok) {
echo "<font face=verdana size=2>The file was successfully sent!</font>";
}else{
die("Sorry but the email could not be sent. Please go back and try again!");
}
?> | | |
|
| PHP based Contact email form with multiple recipients, text file based, supports departments. Categories : PHP, Email, Beginner Guides, Filesystem | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | How to ifconfig down/up a list of IP's Categories : Arrays, Strings, Filesystem, PHP | | | validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email
addresses via SMTP and regex. Categories : Email, Regexps, PHP | | | Download manager - A PHP script for adding a download page to any site.It also enables you track the no. of downloads. Categories : PHP, Content Management, Filesystem, Databases, MySQL | | | Solution to those 'tell-a-friend' type email issues Categories : PHP, Email, Databases, MySQL | | | Working with files - putting file contents to a string / var Categories : PHP, Filesystem, Variables, Strings | | | Easy upload class Categories : PHP Classes, Filesystem, HTTP, PHP | | | how can I read the entire contents of a file into a string? Categories : Filesystem, Strings, PHP | | | filesplit : Split big text files in multiple small ones Categories : PHP, Log Files, Filesystem, PHP Classes | | | Creating a Language File Categories : PHP, Beginner Guides, Filesystem | | | getDirArray(Path,Filter,Sorted): Returns an array of the files in a directory,
filtered by regular expression and either sorted or randomized. Good for
random pictures and graphics. Categories : PHP, Filesystem, Directories | | | Single-file PHP news system with automatic folder structure creation Categories : PHP, Filesystem, Arrays | | | Protect your email links from being spidered by spam email robots! Categories : PHP, Security, Mail, Email | | | Quote For the Day Categories : PHP, Utilities, Filesystem | |
|
|