佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 756|回复: 9

PHP Mail()

[复制链接]
发表于 23-5-2006 11:45 AM | 显示全部楼层 |阅读模式
PHP MAIL()

我想请问各位,我用PHP来send mail,如果是寄plain text 就没有问题。但是,如果我是用寄html格式的mail,在outlook express就看不到。因为它出现在outlookc出现的是源码<html><head>........而不是message itself with formating.
请问,我漏了什么吗?
回复

使用道具 举报


ADVERTISEMENT

发表于 23-5-2006 01:11 PM | 显示全部楼层
你的MIME Header是什么?如果没有用MIME格式的话,你的Mail Client是不会知道你的邮件是什么格式。

参考这里,里面有个例子:

http://sg.php.net/manual/en/function.mail.php

要方便的话,也可以用phpmailer或PEAR::Mail_Mime
回复

使用道具 举报

 楼主| 发表于 23-5-2006 02:31 PM | 显示全部楼层
谢谢你的回复,忘了说明我已经加了mime at header. 还是有人可以给我简单及完整的example吗?我尝试找了好多网页但是找不到答案。
回复

使用道具 举报

发表于 23-5-2006 04:20 PM | 显示全部楼层
PHP的网页不是已经有了吗?
另外,我知道Outlook有一个Read All Standard Mail in Plain Text的功能,Outlook Express就不懂有没有,要确定你没有启动这个功能。

  1. <?php
  2. // multiple recipients
  3. $to  = 'aidan@example.com' . ', '; // note the comma
  4. $to .= 'wez@example.com';

  5. // subject
  6. $subject = 'Birthday Reminders for August';

  7. // message
  8. $message = '
  9. <html>
  10. <head>
  11.   <title>Birthday Reminders for August</title>
  12. </head>
  13. <body>
  14.   <p>Here are the birthdays upcoming in August!</p>
  15.   <table>
  16.    <tr>
  17.      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
  18.    </tr>
  19.    <tr>
  20.      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
  21.    </tr>
  22.    <tr>
  23.      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
  24.    </tr>
  25.   </table>
  26. </body>
  27. </html>
  28. ';

  29. // To send HTML mail, the Content-type header must be set
  30. $headers  = 'MIME-Version: 1.0' . "\r\n";
  31. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

  32. // Additional headers
  33. $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
  34. $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
  35. $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
  36. $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

  37. // Mail it
  38. mail($to, $subject, $message, $headers);
  39. ?>
复制代码
回复

使用道具 举报

 楼主| 发表于 25-5-2006 09:19 AM | 显示全部楼层
谢谢你的回复,以上的example我全都已经试过了,可是还是不能。就连以上的example都不能,它也是只能看到源码,如下。
Content-type: text/html; charset=iso-8859-1
To: Mary <mary@example.com>, Kelly <kelly@example.com>
From: Birthday Reminder <birthday@example.com>
Cc: birthdayarchive@example.com



<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
回复

使用道具 举报

发表于 25-5-2006 09:20 AM | 显示全部楼层
如果是这样, 应该是你的 Email Client 的问题. 试试看是否能把 HTML 功能打开.
回复

使用道具 举报

Follow Us
 楼主| 发表于 25-5-2006 10:28 AM | 显示全部楼层
谢谢你的回复,请问什么是我的Email client? 我是用squirrel mail and qmail.
然后我要在那里做setting把这个功能打开? 不好意思,我在这方面还是新手,所以有劳各位多多指教。
回复

使用道具 举报

发表于 25-5-2006 11:34 AM | 显示全部楼层
原帖由 凡人,烦人? 于 25-5-2006 10:28 AM 发表
谢谢你的回复,请问什么是我的Email client? 我是用squirrel mail and qmail.
然后我要在那里做setting把这个功能打开? 不好意思,我在这方面还是新手,所以有劳各位多多指教。


Email Client 是安装在你电脑上, 用来收和发电邮的软件. 例如 Outlook, Outlook Express, ThunderBird 等. 每个软件的 setting 都有所不同... 你需要去查找各软件的 manual.
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 25-5-2006 11:53 AM | 显示全部楼层
我是用outlook express, 请问我要在那里set? 我已经尝试了各样的setting在我的OE上,还是我漏了什么吗?
还有点,为什么像nokia还是其他的等寄给我的htmlformat的邮件我就可以看?我尝试将MIME 从header丢掉,我的OE就不会看到源码了,可是如果在squirrel mail看的话就会看到源码。
有什么方法可以让两个都可以看到呢?
谢谢!!
回复

使用道具 举报

发表于 25-5-2006 12:25 PM | 显示全部楼层
原帖由 凡人,烦人? 于 25-5-2006 11:53 AM 发表
我是用outlook express, 请问我要在那里set? 我已经尝试了各样的setting在我的OE上,还是我漏了什么吗?
还有点,为什么像nokia还是其他的等寄给我的htmlformat的邮件我就可以看?我尝试将MIME 从header丢掉,我 ...


我不太清楚怎么弄... 因为我没用 outlook. 我建议你 send 去 hotmail 看看, 或用其它的 email client .
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-9-2024 07:42 PM , Processed in 0.133256 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表