天天看點

php email函數發送HTML文本檔案

<?php

//發件人

$from = "[email][email protected][/email]";

//收件人

$email= "[email][email protected][/email]";

//郵件主題 注:防止中文亂碼

$subject  = "=?UTF-8?B?".base64_encode('公司郵件系統')."?=";

//HTML格式頁面

$p_w_upload= "test.html";

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

// Additional headers

$headers .= 'To: Mary <[email][email protected][/email]>, Kelly <'">[email][email protected][/email]>' . "\r\n";

$headers .= 'From: Birthday Reminder <'">[email][email protected][/email]>' . "\r\n";

//打開HTML檔案

$body = '

<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>

      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>

      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>

  </table>

</body>

</html>

';

//發送MAIL

if(mail($email, $subject, $body, $headers))

echo "success!!!";

?>