亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PHP mail() 函數(shù)

定義和用法

mail() 函數(shù)允許您從腳本中直接發(fā)送電子郵件。

如果郵件的投遞被成功地接收,則返回 true,否則返回 false。

語法

mail(to,subject,message,headers,parameters)
參數(shù) 描述
to 必需。規(guī)定郵件的接收者。
subject 必需。規(guī)定郵件的主題。該參數(shù)不能包含任何換行字符。
message 必需。規(guī)定要發(fā)送的消息。
headers 必需。規(guī)定額外的報(bào)頭,比如 From, Cc 以及 Bcc。
parameters 必需。規(guī)定 sendmail 程序的額外參數(shù)。

說明

message 參數(shù)規(guī)定的消息中,行之間必須以一個(gè) LF(\n)分隔。每行不能超過 70 個(gè)字符。

(Windows 下)當(dāng) PHP 直接連接到 SMTP 服務(wù)器時(shí),如果在一行開頭發(fā)現(xiàn)一個(gè)句號(hào),則會(huì)被刪掉。要避免此問題,將單個(gè)句號(hào)替換成兩個(gè)句號(hào)。

<?php
$text = str_replace("\n.", "\n..", $text);
?>

提示和注釋

注釋:您需要緊記,郵件投遞被接受,并不意味著郵件到達(dá)了計(jì)劃的目的地。

例子

例子 1

發(fā)送一封簡(jiǎn)單的郵件:

<?php

$txt = "First line of text\nSecond line of text";

// 如果一行大于 70 個(gè)字符,請(qǐng)使用 wordwrap()。
$txt = wordwrap($txt,70);

// 發(fā)送郵件
mail("somebody@example.com","My subject",$txt);
?>

例子 2

發(fā)送帶有額外報(bào)頭的 email:

<?php

$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";

mail($to,$subject,$txt,$headers);
?>

例子 3

發(fā)送一封 HTML email:

<?php

$to = "somebody@example.com, somebodyelse@example.com";
$subject = "HTML email";

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";

// 當(dāng)發(fā)送 HTML 電子郵件時(shí),請(qǐng)始終設(shè)置 content-type
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// 更多報(bào)頭
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";

mail($to,$subject,$message,$headers);
?>