使用mail发送html正文/表单内容:to function

时间:2014-05-06 14:23:20

标签: php html

我想知道如何使用mail:to功能将HTML,CSS和JavaScript内容附加到电子邮件中?可以做到的是JavaScript还是需要在PHP中完成?提前谢谢!

1 个答案:

答案 0 :(得分:0)

它确实需要在PHP中完成,希望它有所帮助

<?php
 $to = "PUT_RECIPIENT_EMAIL_ADDRESS_HERE";
 $subject = "PUT_SUBJECT_HERE";
 $mail_body = '<html>
 <body bgcolor="#573A28" topmargin="25">
 Put HTML content here with variables from PHP if you like
  Variable display Example: ' . $subject . ' 
 </body>
  </html>';
 $headers  = "From:youremail@yoursite.comrn";
  $headers .= "Content-type: text/htmlrn";
mail($to, $subject, $mail_body, $headers);
 ?>