⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.mail.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Send mail</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.mail.html">Mail Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.mailparse.html">Mailparse</a></div> <div class="up"><a href="ref.mail.html">Mail Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.mail" class="refentry"> <div class="refnamediv">  <h1 class="refname">mail</h1>  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mail</span> &mdash; <span class="dc-title">Send mail</span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">bool</span> <span class="methodname"><b><b>mail</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$to</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$subject</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$message</tt></span>   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$additional_headers</tt></span>   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$additional_parameters</tt></span>  ]] )</div>  <p class="para rdfs-comment">   Sends an email.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">to</tt></i></span>     <dd>      <p class="para">       Receiver, or receivers of the mail.      </p>      <p class="para">       The formatting of this string must comply with       <a href="http://www.faqs.org/rfcs/rfc2822" class="link external">&raquo; RFC 2822</a>. Some examples are:       <ul class="simplelist">        <li class="member">user@example.com</li>        <li class="member">user@example.com, anotheruser@example.com</li>        <li class="member">User &lt;user@example.com&gt;</li>        <li class="member">User &lt;user@example.com&gt;, Another User &lt;anotheruser@example.com&gt;</li>       </ul>      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">subject</tt></i></span>     <dd>      <p class="para">       Subject of the email to be sent.      </p>      <div class="caution"><b class="caution">Caution</b>       <p class="para">        This must not contain any newline characters, or the mail may not be        sent properly.       </p>      </div>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">message</tt></i></span>     <dd>      <p class="para">       Message to be sent.      </p>      <p class="para">       Each line should be separated with a LF (\n). Lines should not be larger       than 70 characters.      </p>      <div class="caution"><b class="caution">Caution</b>       <p class="para">        (Windows only) When PHP is talking to a SMTP server directly, if a full        stop is found on the start of a line, it is removed. To counter-act this,        replace these occurrences with a double dot.        <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$text&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n."</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"\n.."</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>        </div>       </p>      </div>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">additional_headers</tt></i> (optional)</span>     <dd>      <p class="para">       String to be inserted at the end of the email header.      </p>      <p class="para">       This is typically used to add extra headers (From, Cc, and Bcc).       Multiple extra headers should be separated with a CRLF (\r\n).      </p>      <blockquote><p><b class="note">Note</b>:                When sending mail, the mail <em class="emphasis">must</em> contain        a <i>From</i> header. This can be set with the         <i><tt class="parameter">additional_headers</tt></i> parameter, or a default        can be set in <var class="filename">php.ini</var>.       <br />               Failing to do this will result in an error        message similar to <i>Warning: mail(): &quot;sendmail_from&quot; not        set in php.ini or custom &quot;From:&quot; header missing</i>.        The <i>From</i> header sets also        <i>Return-Path</i> under Windows.       <br />      </p></blockquote>      <blockquote><p><b class="note">Note</b>:                If messages are not received, try using a LF (\n) only.        Some poor quality Unix mail transfer agents replace LF by CRLF        automatically (which leads to doubling CR if CRLF is used).        This should be a last resort, as it does not comply with        <a href="http://www.faqs.org/rfcs/rfc2822" class="link external">&raquo; RFC 2822</a>.       <br />      </p></blockquote>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">additional_parameters</tt></i> (optional)</span>     <dd>      <p class="para">       The <i><tt class="parameter">additional_parameters</tt></i> parameter       can be used to pass an additional parameter to the program configured       to use when sending mail using the <i>sendmail_path</i>       configuration setting. For example, this can be used to set the       envelope sender address when using sendmail with the       <i>-f</i> sendmail option.      </p>      <p class="para">       The user that the webserver runs as should be added as a trusted user to the       sendmail configuration to prevent a &#039;X-Warning&#039; header from being added       to the message when the envelope sender (-f) is set using this method.       For sendmail users, this file is <var class="filename">/etc/mail/trusted-users</var>.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns <b><tt>TRUE</tt></b> if the mail was successfully accepted for delivery, <b><tt>FALSE</tt></b> otherwise.  </p>  <p class="para">   It is important to note that just because the mail was accepted for delivery,   it does NOT mean the mail will actually reach the intended destination.  </p> </div> <div class="refsect1 changelog">  <h3 class="title">ChangeLog</h3>  <p class="para">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -