PHP 中的 mail() 函数

programmingserver side programmingphp更新于 2025/8/12 7:22:17

mail() 函数允许直接从脚本发送电子邮件。

语法

mail(to,sub,msg,headers,parameters);

参数

  • to − 电子邮件的收件人

  • sub − 电子邮件的主题。

  • msg − 要发送的消息。

  • headers − 附加标头,例如发件人、抄送和密送。

  • parameters − sendmail 程序的附加参数。该功能已在 PHP 4.0.5 中添加。

返回

mail() 函数返回地址参数的哈希值,失败时返回 FALSE。

示例

以下是发送电子邮件的示例 −

<?php
   $msg = "This is demo text!";
   $email_msg = wordwrap($msg,40);
   mail("demo@example.com","Subject Line",$email_msg);
?>

相关文章