mail script not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have been trying to get this mail script to send an html message and
it just sends the html in plain text with all the html code showing.
Could somebody tell my way this will not work. When it does send it
takes a long time to go through but when I send a plan text message it
goes through right away


$plain_text =
"$firstname $lastname has just accesed your web site.
They went there at $today.
It would be a good time to contact them.
$firstname $lastname Phone number is $phonenumber.
Log in at http://domain.com/login.php";;

$hmessage = "<html>
<head>
   <title></title>
</head>

<body>
<table>
<tr>
   <td><h2>$firstname $lastname has just accesed your web site.<br>They
went there at <font color='#FF0000'>$today</font>.</h2></td>
</tr>
<tr>
   <td><h3>It would be a good time to contact them.<br>$firstname
$lastname Phone number is $phonenumber.</h3>
<br><h3>Log in at <a
href='http://domain.com/login.php'>http://easycontactpro.com/login.php</a></h3></td>
</tr>
</table>
</body>
</html>";


$from="admin@xxxxxxxxxx";
$to="tester@xxxxxxxxxx";
$subject="test";

# Setup mime boundary
   $mime_boundary = 'Multipart_Boundary_x'.md5(time()).'x';

   $headers  = "MIME-Version: 1.0\r\n";
   $headers .= "Content-Type: multipart/alternative;
boundary=\"$mime_boundary\"\r\n";
   $headers .= "Content-Transfer-Encoding: 7bit\r\n";

   $body     = "This is a multi-part message in mime format.\n\n";

   # Add in plain text version
   $body    .= "--$mime_boundary\n";
   $body    .= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n";
   $body    .= "Content-Transfer-Encoding: 7bit\n\n";
   $body    .= $plain_text;
   $body    .= "\n\n";

   # Add in HTML version
   $body    .= "--$mime_boundary\n";
   $body    .= "Content-Type: text/html; charset=\"UTF-8\"\n";
   $body    .= "Content-Transfer-Encoding: 7bit\n\n";
   $body    .= $hmessage;
   $body    .= "\n\n";


   # End email
   $body    .= "--$mime_boundary--\n"; # <-- Notice trailing --,
required to close email body for mime's

   # Finish off headers
   $headers .= "From: $from\r\n";
   $headers .= "X-Sender-IP: $_SERVER[SERVER_ADDR]\r\n";
   $headers .= 'Date: '.date('n/d/Y g:i A')."\r\n";

   # Mail it out
   mail($to, $subject, $body, $headers);



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux