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).

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

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据