关于这个HTML Email

1.What we AlWAYS do?

1.1 position of the css In email,the external stylesheets for the html is not allowed,we just can use inline-style,write the style in the tag attribute.

 

1.2 Use table tag. Spans,divs,ul and ol are used sparingly to achieve specific effects, while HTML tables do the bulk of the layout work. Tables are still the best way to achieve consistent results across email clients. The email equivalent of the browser window is the "viewport", or the area in an email client dedicated to showing the actual email. And we sugguest you to give up the old tags,just like

, and so on.

1.3 reset the style Just like the templates we used to do usually.The only difference is the point 1,you need to write the style in the tags.

1.4. Images should be posted on your publicly accessible web server In your code, use absolute paths to point to them. Attachments are often stored in randomly named temporary cache folders by some email programs. 

2.What we CAN'T do

2.1 Include a section with styles Apple Mail.app supports it, but Gmail and Hotmail do not, so it's a no-no. Hotmail will support a style section in the body but Gmail still doesn't.

2.2 Link to an external stylesheet Not many email clients support this, fotget it.

2.3 Background-image / Background-position Gmail and outlook don’t support this.So,you know it.

2.4 Clear your floats. Oh,use table,forget this.

2.5 Margin Yes, seriously, Hotmail ignores margins. Basically any CSS positioning at all doesn't work.

2.6 Font-xxxxx It will cause some problems you don’t know,and don’t use CSS shorthand.

2.7 Bgcolor Please use whole code like #ffffff,don’t use #fff.

3.To the designer

3.1 If possible,don’t use gradiant event Background is not supported in most emails.

3.2 As simple as possible.

4.CSS Properties

Support for CSS Properties

 

Outlook 2007

Thunderbird

Gmail

Hotmail

Yahoo!

background-color

background-image

background-position

background-repeat

border

border-collapse

border-spacing

clear

color

cursor

display

float

font-family

font-size

font-style

font-weight

height

letter-spacing

line-height

list-style-image

list-style-position

list-style-type

margin

opacity

overflow

padding

position

text-align

text-decoration

text-indent

vertical-align

visibility

white-space

width

word-spacing

z-index


5.Tips

They are also full-service HTML email marketing providers out there. Most noteably, MailChimp. With MailChimp, you design your emails right within their web editor. You still have a nice amount of control, the prefab template is pretty nice, and MailChimp will do everything possible to make sure the email looks it's absolute best in all email clients. That alone is worth the reasonable rates ($30/month for lists up to 2,500 and goes up and down from there). MailChimp offers more though, a service which is almost invaluable, managing your lists for you. You get a customizable web page you can send people to to sign up for your emails, which will automatically add them to your list. Even better, they also handle unsubscribes automatically. Both of these things can be as transparent to you as you would like. Statistics on your emails are provided.
表格整理中...
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你想使用Jinja2来生成HTML电子邮件,可以参考以下步骤: 1. 安装Jinja2库 ``` pip install jinja2 ``` 2. 创建Jinja2模板 在你的Python代码中,你需要创建一个Jinja2模板来生成HTML电子邮件。这可以通过创建一个HTML文件并将其作为Jinja2模板来完成。例如,你可以创建一个名为“email_template.html”的文件,并在其中编写HTML代码和Jinja2模板语法: ```html <html> <head> <title>{{ title }}</title> </head> <body> <h1>{{ heading }}</h1> <p>{{ message }}</p> </body> </html> ``` 在这个模板中,我们使用了Jinja2的模板语法来插入变量。例如,我们使用了“{{ title }}”和“{{ heading }}”来插入标题和标题文本,使用“{{ message }}”来插入消息文本。 3. 渲染Jinja2模板 在你的Python代码中,你需要使用Jinja2库来渲染模板并生成HTML电子邮件。以下是一个简单的Python代码示例: ```python from jinja2 import Environment, FileSystemLoader # 创建Jinja2环境 env = Environment(loader=FileSystemLoader('./')) # 加载模板 template = env.get_template('email_template.html') # 渲染模板 html = template.render(title='Welcome to my website', heading='Hello, World!', message='Thank you for visiting my website!') # 打印HTML代码 print(html) ``` 在这个示例中,我们首先创建了一个Jinja2环境,并使用FileSystemLoader指定了模板文件所在的目录。然后,我们使用get_template()方法加载了模板文件,并使用render()方法将模板渲染为HTML代码。最后,我们将HTML代码打印到控制台上。 4. 发送HTML电子邮件 最后,你需要将HTML代码插入到电子邮件中并发送电子邮件。这可以通过使用Python的smtplib库来实现。以下是一个简单的Python代码示例: ```python import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from jinja2 import Environment, FileSystemLoader # 创建Jinja2环境 env = Environment(loader=FileSystemLoader('./')) # 加载模板 template = env.get_template('email_template.html') # 渲染模板 html = template.render(title='Welcome to my website', heading='Hello, World!', message='Thank you for visiting my website!') # 创建MIME消息 msg = MIMEMultipart() msg['From'] = 'sender@example.com' msg['To'] = 'recipient@example.com' msg['Subject'] = 'Welcome to my website' # 将HTML代码插入到电子邮件中 msg.attach(MIMEText(html, 'html')) # 发送电子邮件 with smtplib.SMTP('smtp.gmail.com', 587) as smtp: smtp.starttls() smtp.login('sender@example.com', 'password') smtp.send_message(msg) ``` 在这个示例中,我们首先创建了一个Jinja2环境,并使用FileSystemLoader指定了模板文件所在的目录。然后,我们使用get_template()方法加载了模板文件,并使用render()方法将模板渲染为HTML代码。接下来,我们创建了一个MIMEMultipart消息,并将HTML代码插入到电子邮件中。最后,我们使用smtplib库将电子邮件发送给收件人。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值