合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
# Mail(核心) [mail()](https://www.php.net/manual/zh/function.mail.php)函数可以让你发送邮件。 - [ezmlm\_hash](https://www.php.net/manual/zh/function.ezmlm-hash.php)— 计算 EZMLM 所需的散列值 - [mail](https://www.php.net/manual/zh/function.mail.php)(string`$收件人列表`,string`$电子邮件的主题`,string`$发送的消息`\[,string`$additional_headers`\[,string`$additional_parameters`\]\] ) :bool— 发送邮件 ``` <pre class="calibre10">``` <span class="token4">ini_set</span><span class="token3">(</span><span class="token2">"SMTP"</span><span class="token3">,</span><span class="token2">"smtp.example.com"</span><span class="token3">)</span><span class="token3">;</span> <span class="token4">ini_set</span><span class="token3">(</span><span class="token2">'sendmail_from'</span><span class="token3">,</span><span class="token2">'user@example.com'</span><span class="token3">)</span><span class="token3">;</span> ``` ``` 例子: ``` <pre class="calibre17">``` $Name <span class="token1">=</span> <span class="token2">"Da Duder"</span><span class="token3">;</span> <span class="token">//senders name</span> $email <span class="token1">=</span> <span class="token2">"email@adress.com"</span><span class="token3">;</span> <span class="token">//senders e-mail adress</span> $recipient <span class="token1">=</span> <span class="token2">"PersonWhoGetsIt@emailadress.com"</span><span class="token3">;</span> <span class="token">//recipient</span> $mail_body <span class="token1">=</span> <span class="token2">"The text for the mail..."</span><span class="token3">;</span> <span class="token">//mail body</span> $subject <span class="token1">=</span> <span class="token2">"Subject for reviever"</span><span class="token3">;</span> <span class="token">//subject</span> $header <span class="token1">=</span> <span class="token2">"From: "</span><span class="token3">.</span> $Name <span class="token3">.</span> <span class="token2">" <"</span> <span class="token3">.</span> $email <span class="token3">.</span> <span class="token2">">\r\n"</span><span class="token3">;</span> <span class="token">//optional headerfields</span> <span class="token4">mail</span><span class="token3">(</span>$recipient<span class="token3">,</span> $subject<span class="token3">,</span> $mail_body<span class="token3">,</span> $header<span class="token3">)</span><span class="token3">;</span> <span class="token">//mail command :)</span> ``` ```