abdullah kahraman
abdullah kahraman

Reputation: 503

PHP: mail() function doesn't work on long html messages

Here is my code:

    $message = '
    <html>
    <body>
    <table>
    <tr>
    <td>
    <img src=http://www.mdrnfx.com/mail_ust.jpg>
    </td>
    </tr>
    <tr>
    <td>
    <br>
    <div align=justify>
    <p>
    <strong>Bugün  demonuzun 2. günü…</strong>
    <br />Öncelikle  bizi tercih ettiğiniz için teşekkür ederiz.
    <br />Forex  piyasasını tanıma ve öğrenme aşamasında mısınız?
    <br />Platformun  kullanımı konusunda desteğe mi ihtiyaç duyuyorsunuz?
    <br />Dilediğiniz  saat için uzaktan bağlantıya geçerek, size yardımcı olmaktan memnuniyet  duyacağımızı bilmenizi isterim.
    <br />Bu  yönde bir talebiniz var ise lütfen aşağıdaki butonu tıklayın, dilediğiniz zaman  sizi arayalım.
    <br />Evet  – hayır
    <br />Evet  ise;
    <br />Sizinle  ne zaman iletişime geçelim : …………………..
    </p>
    <p>
    Aklınıza  takılan her konuda dilediğiniz; zaman bizimle temasa geçebilirsiniz…
    </p>
    <p>
    Saygılarımla
    <br />
    <b>' . $_SESSION['adminName'] . '</b>
    <br />Tel:<b> 0216 545 48 44</b>
    <br />Msn:<b>' . $_SESSION['adminMsn'] . '</b>
    </p>
    Skype: <b>' . $_SESSION['adminSkype'] . '</b>
    </div>
    <br>
    </td>
    </tr>
    <tr>
    <td>
    <img src=http://www.mdrnfx.com/mail_alt.jpg>
    </td>
    </tr>
    </table>
    </body>
    </html>
    ';  
    $subject = "ModernFx - 2. Demo Gününüz";
    $name = "ModernFx";
    $gonderen = $_SESSION['adminMail'];
    $mailler = $_POST['mailler'];
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
    $email = explode("\n", $mailler);
    unset($email[sizeof($email)-1]);;
    //$headers .= "From: ".$name." <".$gonderen.">";
    echo $message;
    echo $headers;
    $i = 0;
    $count = 1;
    while( $i <= (sizeof($email)-1) )
    {
          if( mail($email[$i], $subject, $message, $headers) )
          {
            echo " $count > <b>".$email[$i]."</b> <font color=green>Adresine Teslim Etti...</font><br><hr>";
            $count++;
          }
          else 
          echo " <b>".$email[$i]."</b> <font color=red>Hata gitmedi</font><br><hr>";
          $i++;
    }

It doesn't work with the line //$headers .= "From: ".$name." <".$gonderen.">"; either.. Error reporting and display errors is on in php.ini and is set to -1.

Any help?

Upvotes: 2

Views: 1360

Answers (3)

Jossi Fresco
Jossi Fresco

Reputation: 425

Better, use MIME PEAR and save yourself a lot of trouble and time...

http://pear.php.net/package/Mail_Mime/redirected

Upvotes: 1

Mhd.Jarkas
Mhd.Jarkas

Reputation: 414

This is my code I always use it to send emails , you can try it

<?

$sendTo   = $uemail;
$subject  = "Email Subject";
$headers  = "From: Name<[email protected]>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$message  = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            </head>
            <body>

            </body>
            </html>';

mail($sendTo, $subject, $message, $headers);

?>

Upvotes: 0

abdullah kahraman
abdullah kahraman

Reputation: 503

It was because of the charset and dreamweaver. I've checked the bare file, and the characters were messed up. So, the problem was dreamweaver, checked the encoding, it says west europe.. Na a, should be ISO-8859-9 or UTF-8.. So, I've chosen UTF-8 and retyped, there you go!

Upvotes: 0

Related Questions