note 54863 modified in ref.mail by dbs
| From: | dbs@php.net | Date: | Sun, 08 Jan 2006 13:24:04 +0000 |
| Subject: | note 54863 modified in ref.mail by dbs | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-101401@lists.php.net to get a copy of this message | ||
hi all programmer
this code is a simple code for attachment mail for use whitout class
<?php
$type = array('gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'swf' => 'application/x-shockwave-flash',
'doc' => 'application/x-msword',
'xls' => 'application/x-msexel',
'bilinmiyor' => '"application/x-unknown-content-type"');
$header="";
$message="";
$boundary='--' . md5( uniqid("myboundary") );
$priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4
(Low)', '5 (Lowest)' );
$priority=$priorities[3];
$charset="iso-8859-9";
$ctencoding="8bit";
$subject="merhaba";
$body="merhaba arkada�lar.";
$to="baristasdemir@hotmail.com";
$from="localhost";
$cc=$to;
$bcc=$to;
$sep= chr(13) . chr(10);
$ctype=$type["bilinmiyor"];
$path[]="k9.gif";
//$path[]="kl.mp3";
$disposition="inline";
for($i=0;$i<count($path);$i++){
$message .= "This is a multi-part message in MIME format.\n--$boundary\n";
$message .= "Content-Type: text/plain; charset=$charset\n";
$message .= "Content-Transfer-Encoding: $ctencoding\n\n$body\n";
$basename=basename($path[$i]);
$message .= "--$boundary\n";
$message .= "Content-type: $ctype;\n name=\"$basename\"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: $disposition;\n";
$message .= " filename=\"$basename\"\n";
$linesz= filesize( $path[$i])+1;
$fp= fopen( $path[$i], 'r' );
$content = chunk_split(base64_encode(fread( $fp, $linesz)));
fclose($fp);
$message .= $sep.$content;
}
//_________________________________header_____________________
$header .= "From: $from\n";
$header .= "X-Priority: $priority\n";
$header .= "CC: $cc\n";
$header .= "Mime-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed;\n";
$header .= "boundary=\"$boundary\"\n";
$header .= "Content-Transfer-Encoding: $ctencoding\n";
$header .= "X-Mailer: Php/libMailv1.3\n";
//_________________________________header_____________________
mail($to,$subject,$message."\n",$header);
?>
--was--
hi all programmer
this code is a simple code for attachment mail for use whitout class
<?php
$type = array('gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'swf' => 'application/x-shockwave-flash',
'doc' => 'application/x-msword',
'xls' => 'application/x-msexel',
'bilinmiyor' => '"application/x-unknown-content-type"');
$header="";
$message="";
$boundary='--' . md5( uniqid("myboundary") );
$priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4
(Low)', '5 (Lowest)' );
$priority=$priorities[3];
$charset="iso-8859-9";
$ctencoding="8bit";
$subject="merhaba";
$body="merhaba arkada�lar.";
$to="baristasdemir@hotmail.com";
$from="localhost";
$cc=$to;
$bcc=$to;
$sep= chr(13) . chr(10);
$ctype=$type["bilinmiyor"];
$path[]="k9.gif";
//$path[]="kl.mp3";
$disposition="inline";
for($i=0;$i<count($path);$i++){
$message .= "This is a multi-part message in MIME format.\n--$boundary\n";
$message .= "Content-Type: text/plain; charset=$charset\n";
$message .= "Content-Transfer-Encoding: $ctencoding\n\n$body\n";
$basename=basename($path[$i]);
$message .= "--$boundary\nContent-type: $ctype;\n name=\"$basename\"\n";
$message .= "Content-Transfer-Encoding: base64\nContent-Disposition:";
$message .= " $disposition;\n filename=\"$basename\"\n";
$linesz= filesize( $path[$i])+1;
$fp= fopen( $path[$i], 'r' );
$content = chunk_split(base64_encode(fread( $fp, $linesz)));
fclose($fp);
$message .= $sep.$content;
}
//_________________________________header_____________________
$header .= "From: $from\nX-Priority: $priority\nCC: $cc\n";
$header .= "Mime-Version: 1.0\nContent-Type: multipart/mixed;";
$header .= "\n boundary=\"$boundary\"\n";
$header .= "Content-Transfer-Encoding: $ctencoding\nX-Mailer:";
$header .= " Php/libMailv1.3\n";
//_________________________________header_____________________
mail($to,$subject,$message."\n",$header);
?>
http://php.net/manual/en/ref.mail.php