我有模板php邮件程序,但是我不能在php邮件程序中使用html标签。
formhandler.php
private function compose_mail($post)
{
$content = "Müraciətçinin məlumatları: \n\n";
foreach($post as $name=>$value)
{
$content .= ucwords($name).":\n";
$content .= "$value\n\n";
}
$this->mailer->Body = $content;
}
handler.php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once './vendor/autoload.php';
use FormGuide\Handlx\FormHandler;
$pp = new FormHandler();
$validator = $pp->getValidator();
$pp->sendEmailTo('yelmar.nihad@gmail.com'); // ← Your email here
echo $pp->process($_POST);
答案 0 :(得分:0)
您可以使用br标签代替/ n。
br是HTML换行符,而\ n是源代码中的换行符。
换句话说,当您以呈现的HTML格式查看页面时br会换行,而在查看源代码时\ n会换行。
答案 1 :(得分:0)
您可以添加
$to = 'to@email.com';
$headers = 'Set_bcc_here';
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message = '<h1>Your message / content</h1>';
mail($to, $subject, $message, $headers);
还尝试在您的html头中添加<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table>
<tr><td> /* Your content Here */</td></tr>
</table>
</body>
</html>
答案 2 :(得分:0)
$content = '<table width="80%" cellpadding="3" background="#e0f2f6">
<tr>
<td><h3> <i class="fa fa-envelope"></i> Registration Email</h3></td>
</tr>
<tr>
<td colspan="2">
<div>
<p>Dear, '.$userName.'</p>
<p>
Well Come to our website & Thank you for register here. we are send this email for verify your email and account on our website. Your verification link is <b><a href="#">Click Here</a></b>.
</p>
<p>Website Name,<br />
Thank You,
</p>
</div>
</td>
</tr>
<tr>
<td colspan="2"><strong itemprop="name">Your Address here,</strong><br>
CityName-110011, Country.<br>
+00-0000000000 <br />
<a href="#">info@website.com</a>
</td>
</tr>
</table>';