duanjiushu5063 2014-05-14 13:37
浏览 88
已采纳

PHPMailer不包括带Bootstrap 3的外部css

I have a PHPMailer script that sends an HTML Email (via the code to embed a HTML file). The HTML file is a Bootstrap 3 page that references external CSS files for the bootstrap styling.

The Email works, and is received with images etc., but without any of the CSS. Is there anything special I need to do, or is it not recommended?

There is a similar question here: How can I send HTML mails with included CSS with PHPMailer? but as it's 4 years old, I thought perhaps things may have changed..?!

If not then I guess I'll have to reformat the Email to be HTML only without CSS.

  • 写回答

1条回答 默认 最新

  • dpxbc88022 2014-05-14 13:47
    关注

    Trizz & Carrie are correct -- most email clients that I'm aware of will block external scripts/stylesheets so your best bet is to include the styles you need at the top of the body of the HTML email.

    <style type="text/css">
    
    .some_class {
      /*styles here*/
    }
    
    .another_class {
      /*styles here*/
    }
    
    </style>
    
    <!--now start your html for your email here-->
    

    It's also best practice to give your style classes and ids really unique names to avoid conflict with built-in CSS naming conventions of various email platforms. You can test your code against a variety of email programs with a service like Email on Acid (although this one is not free).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 comsol稳态求解器 找不到解,奇异矩阵有1个空方程返回的解不收敛。没有返回所有参数步长;pid控制
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功