自己写了一个邮件发送得代码(PHP写得),发送邮件得时候别得邮箱都正常,唯独在gmail邮箱下 不正常,显示如下 发件人China Mining Hotels <[email protected]>
发送至liuc changjiang <[email protected]>日期2010年6月1日 下午5:37
主题Submission Confirmation
邮送域163.com隐藏详细信息 17:37 (23 分钟前) charset="GB2312" Content-Transfer-Encoding: base64 X-CM-TRANSID:DtGowLCL5ALv1ARMzyZ1AA--.38660S3 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxUSIJmUUUUU Message-Id: <[email protected]> Date: Tue, 1 Jun 2010 17:37:51 +0800 (CST) X-CM-SenderInfo: 50xk4iivy6il2tof0z/1tbiLhfiAElynJ16bwABs1 ztLAtMrUytTQ0LK70NCwoaOstb2119DQsrvQ0LCho6zOqsm2sfDIy7XE08rP5L7NxNzV/bOjt6LQ xcTYo6y2+M7StcO+zbK70NDE2KOsxvjLwM7Swcs= 
头部正常,就是 主体body 不正常,很是郁闷, 其他邮箱是这样得
Submission Confirmation 
To :liu changjiang Email :[email protected] 
From :China Mining Hotels Tel No.  :+86-22-88353236 
Date :2010-06-01 Hotel Name :Hotel Nikko Tianjin 
Thank you for your reservation.We are pleased to confirm your reservation   
as follows: 
                
Name of Guest  :liu changjiang,23 
Arrival Date  :2010-06-08 No. of Rooms  :1 
Departure Date  :2010-07-05 Room Type  :Double Room 
Room Rate  :$0 Extra Breakfast :0 ($0) 
Total Charge  :$0 Extra Bed :0 ($0) 
Res : 
                
                
Check-in Time  : 1400 hours  Check-out Time  : 1200 hours  
                
Cancellation Policy in June
If you make a reservation and pay during this period, you can enjoy our special price in June. And if you cancel or change your reservation within a week, you don’t need to pay any fees. However, if you cancel or change your reservation after a week, we will take a night of the room rate as the compensation for breach of contract.  
                
For Reservations,please login www.chinamininghotels.com     
or e-mail:[email protected]     
No.84 Qu Fu Road , Heping District , Tianjin , China   
Tel:(86-22) 88353289 88353236 
Fax:(86-22) 88354117 以上内容是有格式得 出来之后 是一个表格形式得,但是在 gmail 邮箱下就是不行,快崩溃了,各位大侠们帮帮忙吧,小弟感激不尽
邮件发送部分如下 function build_content($bound_level=0,$text_body,$html_body,$hava_att=false) 

if ($html_body) 

if (eregi("\<*img[[:space:]]+src[[:space:]]*=[[:space:]]*([^ ]+)",$html_body,$reg)) 

$bound_level++; 
if ($text_body) 

$this->body.="Content-Type: multipart/related; 
type=\"multipart/alternative\"; 
boundary=\""; 
$this->body.=$this->bound_begin.$bound_level.$this->bound_end."\"\r\n\r\n"; 

else 

$this->body.="Content-Type: multipart/related; 
boundary=\""; 
$this->body.=$this->bound_begin.$bound_level.$this->bound_end."\"\r\n\r\n"; 

} // 对于是否 text 正文 、 html正文 有没有,须有不同的 MIME 头 
if (!$hava_att) $this->body.="This is a multi-part message in MIME format.\r\n\r\n"; 
// 正文标识,如果是已经有附件的编码,则在正文 中不需要这一句 
$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."\r\n"; 
$this->parse_html_body($html_body); 
if ($text_body) 

$this->body.="Content-Type: multipart/alternative; 
boundary=\""; 
$bound_level++; 
$this->body.=$this->bound_begin.$bound_level.$this->bound_end."\"\r\n\r\n"; 
$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."\r\n"; 
$this->body.="Content-Type: text/plain;\r\n"; 
$this->body.="charset=\"$this->charset\"\r\n"; 
$this->body.="Content-Transfer-Encoding: base64 \r\n"; 
$this->body.="\r\n".chunk_split(base64_encode(StripSlashes($text_body)))."\r\n"; 
$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."\r\n"; 
$this->body.="Content-Type: text/html;\r\n"; 
$this->body.="charset=\"$this->charset\"\r\n"; 
$this->body.="Content-Transfer-Encoding: base64 \r\n"; 
$this->body.="\r\n".chunk_split(base64_encode(StripSlashes($this->temp_html_body)))."\r\n"; 
$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."--\r\n\r\n"; 
$bound_level--; 

else 

$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."\r\n"; 
$this->body.="Content-Type: text/html;\r\n"; 
$this->body.="charset=\"$this->charset\"\r\n"; 
$this->body.="Content-Transfer-Encoding: base64 \r\n"; 
$this->body.="\r\n".chunk_split(base64_encode(StripSlashes($this->temp_html_body)))."\r\n"; 
} //正文编码,有或没有 text 部分,编成不同的格式。 
for ($i=0;$i<count($this->temp_body_images);$i++) 

$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."\r\n"; 
$this->body.="Content-Type:".$this->temp_body_images[$i][type]."; 
name=\""; 
$this->body.=$this->temp_body_images[$i][name]."\"\r\n"; 
$this->body.="Content-Transfer-Encoding: base64\r\n"; 
$this->body.="Content-ID: <".$this->temp_body_images[$i][cid].">\r\n"; 
$this->body.="\r\n".chunk_split(base64_encode(StripSlashes($this->temp_body_images[$i][data])))."\r\n"; 

$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."--\r\n\r\n"; 
$bound_level--; 

else // 有或没有图片,以上是有图片的处理,下面是没有图片的处理 

$this->temp_html_body=$html_body; 
if ($text_body) 

$bound_level++; 
$this->body.="Content-Type: multipart/alternative; 
boundary=\""; 
$this->body.=$this->bound_begin.$bound_level.$this->bound_end."\"\r\n\r\n"; 

if (!$hava_att) $this->body.="\r\nThis is a multi-part message in MIME format.\r\n\r\n"; 
$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."\r\n"; 
$this->body.="Content-Type: text/plain;\r\n"; 
$this->body.="charset=\"$this->charset\"\r\n"; 
$this->body.="Content-Transfer-Encoding: base64 \r\n"; 
$this->body.="\r\n".chunk_split(base64_encode(StripSlashes($text_body)))."\r\n"; 
$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."\r\n"; 
$this->body.="Content-Type: text/html;\r\n"; 
$this->body.="charset=\"$this->charset\"\r\n"; 
$this->body.="Content-Transfer-Encoding: base64 \r\n"; 
$this->body.="\r\n".chunk_split(base64_encode(StripSlashes($this->temp_html_body)))."\r\n"; 
$this->body.="--".$this->bound_begin.$bound_level.$this->bound_end."--\r\n\r\n"; 
$bound_level--; 

else 

$this->body.="Content-Type: text/html;\r\n"; 

print "thisbody=".$this->body."<br />";



$this->body.="charset=\"$this->charset\"\r\n"; 
$this->body.="Content-Transfer-Encoding: base64 \r\n"; 
$this->body.="\r\n".chunk_split(base64_encode(StripSlashes($this->temp_html_body)))."\r\n"; 
print "thisbody=".$this->body."<br />";

} //正文编码,有或没有 text 部分,编成不同的格式。 

} // end else 

else // 如果没有 html 正文,只有 text 正文  

$this->body.="Content-Type: text/plain; 
charset=\"$this->charset\"\r\n"; 
$this->body.="Content-Transfer-Encoding: base64 \r\n"; 
$this->body.="\r\n".chunk_split(base64_encode(StripSlashes($text_body)))."\r\n"; 

} // end function default 这个方法是构建发送主体得

解决方案 »

  1.   

    应该是 gb2312吧 是utf-8????? 我看别得邮箱 都是 gb2312啊 难道 gmail的是 utf-8 啊
      

  2.   

    gmail这样国际范围的应用不会用gb2312的编码
      

  3.   

    Gmail自动把你的TABLE格式清除了?
      

  4.   


    那是不是 我只要改成 utf-8编码得 就正常了么
      

  5.   

    昨天试了试 utf-8得根本不行,乱码,邮箱得一般都是 gb2312 应该是,中文我用gb2312得发送没问题得,另外我还有一点不解,就是我能够发送不是网页形式得邮件即纯文本形式得邮件完全没问题,一换成 网页形式得就有问题,郁闷死了
      

  6.   

    问题已经解决了,不是编码的问题,是我发送的时候将文字截取成若干段了,分段发送的,所以接收不到,gmail也是gbk的,好像那个hotmail 的是utf-8编码的,其余的邮箱,比如网易,搜狐,新浪 qq,== 邮箱都是gbk编码的