Does Python have a module to convert CSS styles to inline styles for emails?

前端 未结 4 980
陌清茗
陌清茗 2020-12-28 09:07

I know this exists in other languages, but I want it for Python to I can send emails that\'ll show up in GMail, etc.

相关标签:
4条回答
  • 2020-12-28 09:33

    http://blog.doughellmann.com/2008/10/pymotw-smtplib.html great example from doug

    0 讨论(0)
  • 2020-12-28 09:35

    toronado is Fast lxml-based CSS stylesheet inliner.

    Installation : pip install toronado

    Example :

    import toronado
    document = """<html>
    <head>
       <style type="text/css">
          h1 { color: red; }
       </style>
    </head>
    <body><h1>Hello, world.</h1></body>
    </html>"""
    print(toronado.from_string(document))
    
    0 讨论(0)
  • 2020-12-28 09:36

    I had to do the same thing a while back and put the module I made for it up on GitHub https://github.com/rennat/pynliner

    0 讨论(0)
  • 2020-12-28 09:39

    There are now many choices for this. Here are two more in what seems to be decreasing order of activity:

    • Premailer
    • Inline Styler
    0 讨论(0)
提交回复
热议问题