I have seen mail function:
<?
// Attachments
// Any attachment should look like the following and include
// the file name and the path. Add as many as you like.
// $attachments[] = 'c:/path/to/file/filename.ext';
// HTML mail
// Set to TRUE to send HTML tags in the email body or FALSE for plain text email
$html = true;
send_mime_mail($recipient, $subject, $message, $headers, $html, $attachments);
function send_mime_mail($recipient, $subject, $message, $headers = NULL, $html = NULL, $attachments = NULL, $css = NULL)
{
if (!function_exists('mime_content_type')){
function mime_content_type($file){
if(!is_readable($file)) return false;
@$size = getimagesize($file);
if(!empty($size['mime'])){
return($size['mime']);
}else{
$extensions = array('doc' => 'application/msword', 'html'=> 'text/html', 'htm' => 'text/html',
'pdf' => 'application/pdf', 'ppt' => 'application/vnd.ms-powerpoint', 'rtf' => 'text/rtf',
'xls' => 'application/vnd.ms-excel', 'zip' => 'application/zip');
$keys = array_keys($extensions);
$parts = array_reverse(explode('.', $file));
$extension = $parts['0'];
if(in_array($extension, $keys)) return $extensions[$extension];
$data = file_get_contents($filename);
$bad = false;
for($x = 0, $y = strlen($data); !$bad && $x < $y; $x++)
{
$bad = (ord($data{$x}) > 127);
}
if(!$bad) return ('text/plain');
return('application/octet-stream');
}
}
}
function convert_links($string, $protocol = TRUE)
{
$search[] = '/<a\s[^>]*href=[\'"]mailto[^\'"]+)[\'"][^>]*>([^<]+)<\/a>/i';
$search[] = '/<a\s[^>]*href=mailto[^\s>]+)[^>]*>([^<]+)<\/a>/i';
$search[] = '/<a\s[^>]*href=[\'"](http:\/\/[^\'"]+)[\'"][^>]*>([^<]+)<\/a>/i';
$search[] = '/<a\s[^>]*href=(http:\/\/[^\s>]+)[^>]*>([^<]+)<\/a>/i';
$replace = '\2 (\1)';
return(strip_tags(preg_replace($search, $replace, $string)));
}
function html_to_plain($string)
{
$string = preg_replace("(\r\n|\n|\r)", ' ', $string);
$string = preg_replace('/<p>/i', "\n\n", $string);
$string = preg_replace('/(<br>|<br \/>)/i', "\n", $string);
return (convert_links($string));
}
if(!isset($css)) $css = '';
// Generate a boundary string
$mime_boundary = "mime_boundry_multipart/mixed".md5(time())."x";
$alternative_mime_boundary = "mime_boundry_multipart/alternative_".md5(time())."x";
if(empty($headers)) $headers = '';
$headers .= "\nMIME-Version: 1.0\n";
if(count($attachments) > 0){
$headers .= "Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"\n\n";
if(!empty($html) and $html == TRUE){
$content = "This is a multi-part message in MIME format.\n\n".
"--{$mime_boundary}\n".
"Content-Type: multipart/alternative;\n".
" boundary=\"{$alternative_mime_boundary}\"\n\n".
"--{$alternative_mime_boundary}\n".
"Content-Type: text/plain; charset=utf-8; format=flowed\n".
"Content-Transfer-Encoding: 7bit\n\n".
html_to_plain($message)."\n\n".
"--{$alternative_mime_boundary}\n".
"Content-Type: text/html; charset=ISO-8859-1\n".
"Content-Transfer-Encoding: 7bit\n\n".
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n".
"<html>\n".
"<head>\n".
" <style type=\"text/javascript\">\n".
" $css \n".
" </style>\n".
" <meta content=\"text/html;charset=utf-8\" http-equiv=\"Content-Type\">\n".
" <title></title>\n".
"</head>\n".
"<body>\n".
$message."\n".
"</body>\n".
"</html>\n\n".
"--{$alternative_mime_boundary}--\n";
}else{
$content = "This is a multi-part message in MIME format.\n\n".
"--{$mime_boundary}\n".
"Content-Type: text/plain; charset=utf-8; format=flowed\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
convert_links($message)."\n\n";
}
// Deal with attachments array
if(count($attachments) > 0){
foreach($attachments as $key => $value){
$mime_type = mime_content_type($value);
if(is_file($value) and is_readable($value) ){
if(ereg('^image', $mime_type)){
$disposition = 'inline';
}else{
$disposition = 'attachment';
}
$filesize = filesize($value);
$file = fopen($value,'rb');
$data = fread($file,$filesize);
fclose($file);
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
$value = pathinfo($value);
$content .= "--{$mime_boundary}\n" .
"Content-Type: $mime_type;\n" .
" name=\"{$value['basename']}\"\n" .
"Content-Transfer-Encoding: base64\n" .
"Content-Disposition: $disposition;\n" .
" filename=\"{$value['basename']}\"\n\n" .
$data . "\n";
}
}
}
$content .= "--{$mime_boundary}--\n";
}elseif(!empty($html) and $html == TRUE){
$headers .= "Content-Type: multipart/alternative;\n".
" boundary=\"{$alternative_mime_boundary}\"\n\n";
$content = "--{$alternative_mime_boundary}\n".
"Content-Type: text/plain; charset=utf-8; format=flowed\n".
"Content-Transfer-Encoding: 7bit\n\n".
html_to_plain($message)."\n\n".
"--{$alternative_mime_boundary}\n".
"Content-Type: text/html; charset=utf-8\n".
"Content-Transfer-Encoding: 7bit\n\n".
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n".
"<html>\n".
"<head>\n".
" <style type=\"text/javascript\">\n".
" $css \n".
" </style>\n".
" <meta content=\"text/html;charset=utf-8\" http-equiv=\"Content-Type\">\n".
" <title></title>\n".
"</head>\n".
"<body>\n".
$message."\n".
"</body>\n".
"</html>\n\n".
"--{$alternative_mime_boundary}--\n";
}else{
$headers .= "Content-Type: text/plain; charset=utf-8; format=flowed\n" .
"Content-Transfer-Encoding: 7bit\n\n";
$content = convert_links($message)."\n";
}
if(mail($recipient, $subject, $content, $headers)) return TRUE;
return FALSE;
}
?>
Do you know how to do that in subject it will work special characters like e.g. ลก č ?