Page 1 of 1

Mailing html?

Posted: Fri Jun 16, 2006 4:38 pm
by JellyFish
Hello, I've used:

Code: Select all

$contents = "<a href='http://www.whatever.com/activate.php?id=$id'>Click here</a>";

mail($_POST[email], 'blablabla', $contents, 'From: yada yada');
And the email that it sends returns:
not:
Click here
Why is that?

Posted: Fri Jun 16, 2006 5:17 pm
by RobertGonzalez
Content type. Read the PHP Manual section on mail(). This comes right out of the PHP manual page for the mail() function...

Code: Select all

<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
   <tr>
     <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
   </tr>
   <tr>
     <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
   </tr>
   <tr>
     <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
   </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?> 

Posted: Fri Jun 16, 2006 5:21 pm
by Christopher
You also may want to try PHPMailer or Swift Mailer (which is developed by a member of this forums)

Posted: Fri Jun 16, 2006 8:08 pm
by JellyFish
Nice. :)

This is good stuff. Thanks mates. :D