用php邮件设置邮件地址的样式

时间:2018-09-25 09:31:39

标签: php email

我尝试用php发送电子邮件。收到Apple Mail时,我看到带有链接的地址:蓝色和带下划线的颜色。也许其他邮件服务也会发生这种情况。如何在php发送的邮件中设置邮件地址的样式?我想拥有控制权

<?php

$to = htmlspecialchars("info@example.com");
$subject = htmlspecialchars("Subject");

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>

<table>

<tr>
    <td style='outline:0; text-decoration: none;'>
    info@example.com</td>
</tr>
</table>

</body>
</html>
";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <info@example2.com>' . "\r\n";

mail($to, $subject, $message, $headers);    

?>

2 个答案:

答案 0 :(得分:1)

包装电子邮件地址

<a href="mailto:info@example.com">info@example.com</a>

答案 1 :(得分:1)

您可以在中添加标签。并简单地用作普通的html页面。 在先前的项目中进行过尝试,并且像一个饰物一样工作。

<?php

$to = htmlspecialchars("info@example.com");
$subject = htmlspecialchars("Subject");

$message = "
<html>
<head>

<style>
td{outline:0; text-decoration: none;}
p{font-weight:bold;color:red;}
a{text-decoration: none; border: 0; color: red; font-weight:bold;}
</style>

<title>HTML email</title>
</head>
<body>

<table>

<tr>
    <td><a href="mailto:info@example.com">info@example.com</a></td>
</tr>
</table>
<p>My paragraph has style !</p>
</body>
</html>
";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <info@example2.com>' . "\r\n";

mail($to, $subject, $message, $headers);    

?>