"Oliver Witt" <[EMAIL PROTECTED]> ???/ ?
?: news:[EMAIL PROTECTED]...
> Hi,
> Can you attach files to emails and send them through a php script? If
> so, how?
> Kind regards,
> Oliver
>
You can use this function. It can attach just one file.
$mode = message type: plain (default) or HTML otherwise
function
SendMail($email,$subject,$body,$from="",$mode="plain",$file_name="",$file_ty
pe="",$no_template=0)
{
$body_prefix="";
$body_suffix="";
$from_suffix="";
if(!empty($file_name))
{
$file=fopen($file_name,"r");
if($file)
{
$file_content="";
while(!feof($file))
$file_content.=fread($file,4096);
fclose($file);
$file_name=basename($file_name);
$body_prefix="This is a multi-part message in MIME format.
--Part012345678
Content-Type: text/$mode; charset=\"ISO-8859-1\"
";
$body_suffix="
--Part012345678
Content-Type: ".( empty($file_type) ? "application/octet-stream" :
$file_type )."; name=\"$file_name\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$file_name\"
".chunk_split(base64_encode($file_content))."
--Part012345678--
";
$from_suffix="
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=\"Part012345678\"";
}
}
else
{
$from_suffix="
MIME-Version: 1.0
Content-Type: text/$mode; charset=\"ISO-8859-1\"";
}
$result=@mail(trim($email),trim($subject),$body_prefix.$body.$body_suffix,"F
rom: ".$from.$from_suffix);
return $result;
}
WBR,
Mike Tsapenko
Chief of Web-development Dept.
AlarIT
http://www.AlarIT.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php