python利用smtplib发送html邮件在exchange遇见的问题


总结下,在exchange做mta的情况,html邮件不能用 <pre>标签,  哥就是被这个郁闷的死去活来的。

发送html邮件是很平常的事情,但是不知道啥原因 ,  这次始终有问题,最后才确定是pre  。。。 


import smtplib
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.MIMEMultipart import MIMEMultipart

def HtmlContent(info,url='',url_msg='',url_img=''):

    content='''
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>Demo: CSS3 Buttons</title>
<style type="text/css">

.download {
    display: inline-block;
    margin-top: 20px;
    padding: 15px;
    font-size: 26px;
    font-weight: bold;
    color: #fff;
    text-shadow: none;
    border-radius: 4px;
    -webkit-animation-name: fadeIn;
    -moz-animation-name: fadeIn;
    -ms-animation-name: fadeIn;
    -o-animation-name: fadeIn;
    animation-name: fadeIn;
    -webkit-animation-delay: .9s;
    -webkit-animation-fill-mode: both;
    -webkit-animation-duration: 1.2s;
    -webkit-animation-iteration-count: 1;
    -webkit-animation-timing-function: ease;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.download:hover {
    -webkit-transform: scale(1.1);
    -moz-transform: scale(1.1);
    -o-transform: scale(1.1);
    transform: scale(1.1);
}

a {
text-decoration: none;
}


div.twitter {
    font-size: 20px;
    padding: 5px;
    color: #fff;
    background: #2da1ec;
    border-radius: 3px;
}

div.twitter:hover {
    color: #fff;
    background: #2eacff;
}

div.twitter:active {
    top: 1px;
}

  padding: 0px 20.48px;
}



</style>
</head>

<body>

<div>
</div>
<!--     <div class="twitter" data-tip="twitter"> -->
 <table width="750" border="1" cellpadding="0" cellspacing="0" style="border:0px solid #ff0000">
            %s
        </table>
<!--     </div> -->

<br>

<br>
<a href="%s">%s</a>
<br>
<br>
<br>
<img src="%s" />
<br>
</body>
</html>

'''%(info,url,url_msg,url_img)
    return content


大家觉得文章对你有些作用! 如果想赏钱,可以用微信扫描下面的二维码,感谢!
另外再次标注博客原地址  xiaorui.cc

发表评论

邮箱地址不会被公开。 必填项已用*标注