Send mail with attachment php

Комментарии отключены

function XMailAttach($from, $to, $subj, $text, $ar_File)
{
	$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";  

	foreach ($ar_File as $file)
	{
		$f         = fopen($file, "rb");
		$zag      .= "------------".$un."\n";
		$zag      .= "Content-Type: application/octet-stream;";
		$zag      .= "name=\"".basename($file)."\"\n";
		$zag      .= "Content-Transfer-Encoding:base64\n";
		$zag      .= "Content-Disposition:attachment;";
		$zag      .= "filename=\"".basename($file)."\"\n\n";
		$zag      .= chunk_split(base64_encode(fread($f,filesize($file))))."\n";
	}

	if (!mail($to, $subj, $zag, $head))
	 	return false;
	else
		return true;
}

И еще вот что есть...

Comments are closed.