PHP如何使用MAIL函数发邮件

最好写个小程序演示一下

PHP mail 发送邮件
mail
(PHP 4, PHP 5)

mail — 发送邮件

说明
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
发送一封电子邮件。

参数
to
电子邮件收件人,或收件人列表。

本字符串的格式必须符合 » RFC 2822。例如:

[email protected]
[email protected], [email protected]
User <[email protected]>
User <[email protected]>, Another User <[email protected]>
subject
电子邮件的主题。

Caution
本项不能包含任何换行符,否则邮件可能无法正确发送。

message
所要发送的消息。

行之间必须以一个 LF( )分隔。每行不能超过 70 个字符。

Caution
(Windows 下)当 PHP 直接连接到 SMTP 服务器时,如果在一行开头发现一个句号,则会被删掉。要避免此问题,将单个句号替换成两个句号。 <?php
$text = str_replace(" .", " ..", $text);
?>

additional_headers(可选项)
String to be inserted at the end of the email header.

This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF ( ).
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-04-13
$to = [email protected];
$subject = "=?UTF-8?B?".base64_encode('邮件标题')."?="; //防止乱码
$message = '邮件内容';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; //Additional headers
$headers .= 'Reply-To: Admin<[email protected]>' . "\r\n";
$headers .= 'From: Admin<[email protected]>' . "\r\n";
mail($to,$subject,$message,$headers);

这是比较通用的PHP发邮件方法,祝你好运!本回答被提问者采纳
第2个回答  2010-04-13
if(@mail("[email protected]","邮件标题","邮件内容")){
echo "成功";
}