简体   繁体   English

PHP邮件格式

[英]PHP Mail Formatting

I'm trying to send an email with html formatting, but when it arrives (in gmail and on my phone), it has had all the tags removed and just a few lines of the text (no < or > ). 我正在尝试发送具有html格式的电子邮件,但是当它到达(在gmail和我的手机上)时,它已删除了所有标签,并且仅删除了几行文字(没有<> )。 I have the header MIME-Version and content-type set correctly, and when I take the original message and place that into an html file, it shows with all the text. 我正确设置了标题MIME-Versioncontent-type ,当我将原始消息放入HTML文件中时,它会显示所有文本。 There are no class attributes set, but rather all stored in the style attribute. 没有设置class属性,而是全部存储在style属性中。 Does anyone know what is removing the tags and styling? 有人知道删除标签和样式的原因吗? Is it Gmail, or something I'm missing? 是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>

Styling emails is very limited, there are very few rules that are accepted and usually you set them inline style. 电子邮件的样式非常有限,几乎没有规则被接受,通常您将它们设置为内联样式。

Html email templates: HTML电子邮件模板:

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

Sorry if I misunderstood the question, if so, let me know. 抱歉,如果我误解了这个问题,请告诉我。

I don't know that this is the cause, because different mail clients and webmails will interpret it differently, but your email is definitely invalid, according to RFC 2822 ; 我不知道这是原因,因为根据RFC 2822 ,不同的邮件客户端和Webmail会对它的解释有所不同,但是您的电子邮件绝对无效。 so you're likely to run into problems at some point. 因此您有时可能会遇到问题。

  • Lines of characters in the body MUST be limited to 998 characters, and SHOULD be limited to 78 characters, excluding the CRLF. 正文中的字符行必须限制为998个字符,并且应限制为78个字符(不包括CRLF)。

I count your HTML line as being 1494 characters long, so you MUST wrap it onto at least two lines. 我认为您的HTML行长度为1494个字符,因此您必须将其包装在至少两行上。

You would normally see lines of 80 characters (including CRLF), but that's mainly for display purposes (and dates back to a time when computer monitors ran significantly lower resolutions). 通常,您会看到80个字符的行(包括CRLF),但这主要是出于显示目的(并且可以追溯到计算机显示器以较低的分辨率运行的时间)。 The limit of 1000 characters (including CRLF) is much more important. 1000个字符(包括CRLF)的限制更为重要。

Also make sure you are using CRLF to separate each line. 另外,请确保使用CRLF分隔每行。

抱歉,我是个傻瓜,我忘记了在style=" ,您需要编写3D 。现在效果不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM