Created
October 30, 2013 05:42
-
-
Save DenimTornado/7227698 to your computer and use it in GitHub Desktop.
Отправка файла по почте From http://www.cyberforum.ru/php/thread55150.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function xmail( $from, $to, $subj, $text, $filename) { | |
$f = fopen($filename,"rb"); | |
$un = strtoupper(uniqid(time())); | |
$head = "From: $from\n"; | |
$head .= "To: $to\n"; | |
$head .= "Subject: $subj\n"; | |
$head .= "X-Mailer: PHPMail Tool\n"; | |
$head .= "Reply-To: $from\n"; | |
$head .= "Mime-Version: 1.0\n"; | |
$head .= "Content-Type:multipart/mixed;"; | |
$head .= "boundary=\"----------".$un."\"\n\n"; | |
$zag = "------------".$un."\nContent-Type:text/html;\n"; | |
$zag .= "Content-Transfer-Encoding: 8bit\n\n$text\n\n"; | |
$zag .= "------------".$un."\n"; | |
$zag .= "Content-Type: application/octet-stream;"; | |
$zag .= "name=\"".basename($filename)."\"\n"; | |
$zag .= "Content-Transfer-Encoding:base64\n"; | |
$zag .= "Content-Disposition:attachment;"; | |
$zag .= "filename=\"".basename($filename)."\"\n\n"; | |
$zag .= chunk_split(base64_encode(fread($f,filesize($filename))))."\n"; | |
return @mail("$to", "$subj", $zag, $head); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment