PHP邮件格式

时间:2012-02-20 18:46:24

标签: php email

我正在尝试发送一封包含html格式的电子邮件,但是当它到达时(在gmail和我的手机上),它已删除了所有标签,只有几行文字(没有<>)。我正确设置了标头MIME-Versioncontent-type,当我将原始邮件放入html文件时,它会显示所有文本。没有设置class个属性,而是全部存储在style属性中。有谁知道什么是删除标签和样式?是Gmail,还是我缺少的东西?

Delivered-To: xxx@gmail.com
Received: by 10.220.91.15 with SMTP id xxxxxxxxx;
        Mon, 20 Feb 2012 10:41:39 -0800 (PST)
Received: by 10.180.90.225 with SMTP id xxxxxxxxx;
        Mon, 20 Feb 2012 10:41:39 -0800 (PST)
Return-Path: <xxxxxxxxx@xxxxxxxxx.net>
Received: from xxxxxxxxx.net (xxxxxxxxx.net. [xxx.xxx.xxx.xxx])
        by mx.google.com with ESMTPS id xxxxxxxxx
        (version=TLSv1/SSLv3 cipher=OTHER);
        Mon, 20 Feb 2012 10:41:39 -0800 (PST)
Received-SPF: pass client-ip=xxx.xxx.xxx.xxx;
Authentication-Results: mx.google.com; spf=pass smtp.mail=xxxxxxxxx.net
Received: from xxxxxxxxx by xxxxxxxxx.net with local (Exim 4.69)
    (envelope-from <xxxxxxxxx@xxxxxxxxx.net>)
    id xxxxxxxxx
    for xxxxxxxxx@xxxxxxxxx.com; Mon, 20 Feb 2012 18:41:34 +0000
To: xxxxxxxxx@gmail.com
Subject: Email Subject
X-PHP-Script: xxxxxxxxx.co.uk/cronjob.php for xxx.xxx.xxx.xxx
From: xxxxxxxx <no-reply@xxxxxxxxx.co.uk>
MIME-Version: 1.0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Message-Id: <xxxxxxxxx@xxxxxxxxx.net>
Date: Mon, 20 Feb 2012 18:41:34 +0000
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - xxxxxxxxx.net
X-AntiAbuse: Original Domain - gmail.com
X-AntiAbuse: Originator/Caller UID/GID - [1119 32003] / [47 12]
X-AntiAbuse: Sender Address Domain - xxxxxxxxx.net
X-Source: /usr/local/lsws/fcgi-bin/lsphp-5.2.17
X-Source-Args: lsphp5:dig/public_html/xxxxxxxxx/cronjob.php
X-Source-Dir: xxxxxxxxx.co.uk:/public_html

<html><body style="color: #333;font-family: 'Myriad Pro';font-size: 18px;margin: 0;padding: 0;text-align: center;"><div style="background-color: #9C3;background-repeat: no-repeat;border: solid 1px #9C3;height: 32px;margin: 0 auto;width: 400px;"></div><div style="background-color: #FFF;border-bottom: solid 1px #9C3;border-left: solid 1px #9C3;border-right: solid 1px #9C3;margin: 0 auto;padding-bottom: 50px;width: 400px;"><div style="border-bottom: solid 1px #E1E1E1;padding-bottom: 10px;padding-top: 20px;">Hi xxxx,<br /><br />Here is a daily digest of recent interaction<br />regarding your activities.<br /><strong>Your attention is required</strong><br /></div><div style="background-color: #F3F3F3;border-bottom: solid 1px #E1E1E1;padding: 10px 0;"><div style="font-size: 20px;">Item 1</div><div style="color: #0066FF;font-size: 16px;">Booking Requested</div><div style="font-size: 14px;">Made by xxxx for 17:30 on Tue, Mar 13th 2012</div></div><div style="background-color: #F3F3F3;border-bottom: solid 1px #E1E1E1;padding: 10px 0;"><div style="font-size: 20px;">Item 2</div><div style="color: #0066FF;font-size: 16px;">Booking Requested</div><div style="font-size: 14px;">Made by xxxx for 18:15 on Tue, Mar 6th 2012</div></div><br /><br /><a href="#" style="background-color: #99CC33;border: solid 1px #64A100;border-radius: 7px;color: #fff;margin: 3px 2px 3px 2px;padding: 7px 10px;text-align: center;text-decoration: none;cursor: pointer;cursor: hand;">Login</a></div></body></html>

3 个答案:

答案 0 :(得分:1)

样式化电子邮件非常有限,很少有规则被接受,通常你会将它们设置为内联样式。

Html电子邮件模板:

电子邮件中的CSS支持:http://www.campaignmonitor.com/css/

对不起,如果我误解了这个问题,如果是的话,请告诉我。

答案 1 :(得分:0)

知道这是原因,因为不同的邮件客户端和网络邮件会以不同的方式解释它,但根据RFC 2822,您的电子邮件肯定无效;所以你可能会在某些时候遇到问题。

  
      
  • 正文中的字符行必须限制为998个字符,    并且应该限制在78个字符以外,不包括CRLF。
  •   

我将您的HTML行计为1494个字符长,因此您必须将其包装到至少两行。

您通常会看到80个字符的行(包括CRLF),但这主要用于显示目的(并且可以追溯到计算机显示器运行时显着降低分辨率的时间)。 1000个字符(包括CRLF)的限制更为重要。

还要确保使用CRLF分隔每一行。

答案 2 :(得分:0)

抱歉,我是个傻瓜,我忘了在style="之间,你需要写3D。现在工作很精彩。