doulu1907
2016-08-07 14:50
采纳率: 100%
浏览 60
已采纳

如何使用BOOTSTRAP格式在PHP中发送HTML邮件

What's the best way to construct and send an HTML email using mail()with bootstrap formatting? I've tried the following example (not full code):

$msg = "
<html>
<head>
<link href = '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' rel='stylesheet' type='text/css'>
</head>
<body>
<p>This is a request to reset your password</p>
<a href='blah'>Click here to reset your password.</a>
<button type='submit' class='btn btn-info btn-sm'>Reset</button>
</body>
</html>
";
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html; charset=iso-8859-1"."
"; "X-Mailer: php".
$headers .= 'From: Password Reset <passwordreset@blah.co.uk>' . "
";

The mail sends and is received in html but not formatted.

图片转代码服务由CSDN问答提供 功能建议

使用带有引导程序的 mail()构建和发送HTML电子邮件的最佳方法是什么? 格式化? 我尝试过以下示例(不是完整代码):

  $ msg =“
&lt; html&gt; 
&lt; head&gt; 
&lt; link href =  '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'rel ='stylesheet'type ='text / css'&gt; 
&lt; / head&gt; 
&lt; body&gt; 
&lt;  ; p&gt;这是重置密码的请求&lt; / p&gt; 
&lt; a href ='blah'&gt;点击此处重置密码。&lt; / a&gt; 
&lt; button type ='submit'class ='  btn btn-info btn-sm'&gt;重置&lt; / button&gt; 
&lt; / body&gt; 
&lt; / html&gt; 
“; 
 $ headers =”MIME-Version:1.0“。  “
 
”; 
 $ headers。=“Content-type:text / html; charset = iso-8859-1”。“
 
”;  “X-Mailer:php”。
 $ headers。='来自:密码重置&lt; passwordreset@blah.co.uk>'  。  “
 
”; 
   
 
 

邮件发送并以html格式收到但未格式化。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanniling0018 2016-08-07 14:53
    已采纳

    Unless you put all of the bootstrap code directly in your email, no. Email clients remove remote files by default to prevent user tracking. You cannot code around this.

    点赞 打赏 评论

相关推荐 更多相似问题