php mail func. encoding problem

heinzketchup

New Member
Messages
25
Reaction score
0
Points
0
could please any of you php gurus analyze my mailing code... sorry, but you can't test it, the problem appears as far as i know only on the mailing account of inode.at. the code works perfect on most of the mailing accounts like gmx.at, hotmail.com and web.de. but i have troubles with inode.at. umlauts are shown as if they are not known. i tried another code and it worked perfectly but i want this code because of all it's features.

My idea: i think some mailing accounts don't accept utf-8... but the subject for example is base64, what i am pretty proud of (see my tut: http://forums.x10hosting.com/tutorials/75495-utf-8-encoded-php-mail-subject-umlauts-problem.html)

by the way... i still don't know how they do the win/mac recognition but if i could put it out, i would but everytime i try, i destroy something i need to run it. The code should be as performant as possible, i use it in a loop. it would also be cool if i could put it out of the function so i could use the header for the encoding...

PS: i am from austria, don't wonder if you can't read some texts... ;)

thanks in advance! i am happy about everything that can help!!!

function send_mail($MailTo, $SenderName, $SenderMail, $Subject, $Mailcontent, $Attachment, $Servername, $nohtml){
if(strtoupper(substr(PHP_OS,0,3)=='WIN')){
$eol="\r\n";
$sol="\n";
}elseif(strtoupper(substr(PHP_OS,0,3)=='MAC')){
$eol="\r";
}else{
$eol="\n";
}
if(!isset($sol)){
$sol = $eol;
}
$Momentn = mktime().".".md5(rand(1000,9999));
$f_name = $Attachment;
$handle = fopen($f_name, 'rb');
$f_contents = @fread($handle, filesize($f_name));
$f_contents = base64_encode($f_contents);
if($handle){
$sendfile = true;
if(ini_get('mime_magic.debug')){
$Bestype = @mime_content_type($Attachment);
}else{
$Bestype = 'application/octet-stream';
}
if(!$Bestype){
$Bestype = 'application/octet-stream';
}
$file_realname = explode("/", $Attachment);
$file_realname = $file_realname[count($file_realname)-1];
$file_realname = explode("\\", $file_realname);
$file_realname = $file_realname[count($file_realname)-1];
}
@fclose($handle);
$Mailcontentstri = explode($sol, $Mailcontent);
$Mailcontentstrip = strip_tags($Mailcontentstri[0]);

if(file_exists($Mailcontentstrip)){
ob_start();
if(require($Mailcontent)){
$body = ob_get_contents();
}
ob_end_clean();
}else{
if(count($Mailcontentstri) < 2){
$body = "Error loading file!<br/>";
$error = true;
}else{
$body = $Mailcontent;
}
}

$Textmsg = eregi_replace("<br(.{0,2})>", $eol, $body);
$Textmsg = eregi_replace("</p>", $eol, $Textmsg);
$Textmsg = strip_tags($Textmsg);
$Textmsg = $nohtml.$eol.$eol.$Textmsg;
$headers .= 'To: '.$MailTo.' <'.$MailTo.'>'.$eol;
$headers .= 'From: '.$SenderName.' <'.$SenderMail.'>'.$eol;
$headers .= "Message-ID: <".$Momentn."@".$Servername.">".$eol;
$headers .= 'Date: '.date("r").$eol;
$headers .= 'Sender-IP: '.$_SERVER["REMOTE_ADDR"].$eol;
$headers .= 'X-Mailser: iPublications Adv.PHP Mailer 1.6'.$eol;
$headers .= 'MIME-Version: 1.0'.$eol;
$bndp = md5(time()).rand(1000,9999);
$headers .= "Content-Type: multipart/mixed; $eol boundary=\"".$bndp."\"".$eol.$eol;
$msg = "This is a multi-part message in MIME format.".$eol.$eol;
$msg .= "--".$bndp.$eol;
$bnd = md5(time()).rand(1000,9999);
$msg .= "Content-Type: multipart/alternative; $eol boundary=\"".$bnd."\"".$eol.$eol;
$msg .= "--".$bnd.$eol;
$msg .= "Content-Type: text/plain; charset=utf-8".$eol;
$msg .= 'Content-Transfer-Encoding: 8-bit"'.$eol.$eol;
$msg .= $Textmsg.$eol;
$msg .= "--".$bnd.$eol;
$msg .= "Content-Type: text/html; charset=utf-8".$eol;
$msg .= "Content-Transfer-Encoding: 8-bit".$eol.$eol;
$msg .= $body.$eol;
$msg .= "--".$bnd."--".$eol.$eol;
if(isset($sendfile)){
$msg .= "--".$bndp.$eol;
$msg .= "Content-Type: $Bestype; name=\"".$file_realname."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Disposition: attachment;".$eol;
$msg .= " filename=\"".$file_realname."\"".$eol.$eol;
$f_contents = chunk_split($f_contents);
$msg .= $f_contents.$eol;
}
$msg .= "--".$bndp."--";


if(!isset($error)){
if(mail($MailTo, $Subject, $msg, $headers)){
echo '<b><font color="#248F11">Eine E-Mail wurde erfolgreich versendet!</font></b><br/><br/>';
return true;
}else{
echo '<b><font color="##EF0E0E">Fehler! E-Mail wurde <u>NICHT</u> versendet!!!</font></b><br/><br/>';
return false;
}
}else{
return false;
}
}
 

ykirby

New Member
Messages
9
Reaction score
0
Points
0
Hi,

I think there might be a problem with x10Hosting- did you check to see if your php mail is enabled?
 
Top