tags:

views:

47

answers:

2

Every time i use this script i get random symbols appear in the email. Is it the character type in the headers. If so what are the correct character type to use?

    $icontent = nl2br($icontent);

    $str = "<html>";
    $str .= "<head>";
    $str .= "<title>Mail</title>";
    $str .= "<style type='text/css'>";
    $str .= "<!--";

    $str .= "body {";
    $str .= "   background-color:#FFFFFF;";
    $str .= "   margin:0px;";
    $str .= "   font-family:Arial;";
    $str .= "   padding:0px;";
    $str .= "}";

    $str .= "</style></head>";

    $str .= "<body>";
    $str .= "<center>";

    $str .= "<div class='logo'>";
    $str .= "<span style='font-size:12px'>$subject</span><br />";
    $str .= "<span style='font-size:10px; font-weight:normal'>" . date("d M Y H:i") . "</span><br />";
    $str .= "</div>";

    $str .= "<div class='content'>";
    $str .= $icontent;
    $str .= "</div>";

    $str .= "<div class='credit'>";
    $str .= "This e-mail is confidential.";
    $str .= "</div>";

    $str .= "</center>";
    $str .= "</body>";
    $str .= "</html>";

    $headers = "MIME-Version: 1.0rn"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1rn"; 
    $headers = "From: Us <[email protected]>\r\n";
    $headers .= "Content-type: text/html\r\n";

    mail($to, $subject, $str, $headers);

I will add im using Fedora 10

Thanks in advance

+1  A: 
$headers = "MIME-Version: 1.0\r\n"; // backslashes missing
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";  // backslashes missing
$headers .= "From: Us <[email protected]>\r\n"; // "." missing before "="
$headers .= "Content-type: text/html\r\n";

The probleme was that you sent only the last 2 headers.

OcuS
Oh yep, Just saw that fixed it: But same issues unfortunatly :(
Shahmir Javaid
It worked awsome.. Thanks
Shahmir Javaid
+1  A: 
    $str .= "<head>";
    $str .= "<title>Mail</title>";
    $str .= "<style type='text/css'>";

// This HTML comment is never closed:
    $str .= "<!--";

    $str .= "body {";
    $str .= "   background-color:#FFFFFF;";
    $str .= "   margin:0px;";
    $str .= "   font-family:Arial;";
    $str .= "   padding:0px;";
    $str .= "}";

//    add this line:    
    $str .= "-->";

    $str .= "</style></head>";
echo
Wait its there.. It just got removed on copy and paste. Plus 1 for well spoted
Shahmir Javaid