很多站长朋友们都不太清楚php使用mail,今天小编就来给大家整理php使用mail,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 如何在php用mail发送邮件 2、 如何使用php的mail函数发送邮件 3、 PHP如何使用MAIL函数发邮件 如何在php用mail发送邮件有两种方法
一、使用PHP内置的mail()函数
二、使用封装SMTP协议的邮件类
具体可以参考这篇文章,希望对你有帮助
如何使用php的mail函数发送邮件如果需要用php的mail()函数来发送邮件,是需要服务器安装sendmail组件才能支持的,这个在php的手册中mail()函数部分也有介绍到。在Ubuntu下安装sendmail的命令:sudo apt-get install sendmail安装好之后,启动sendmail服务:sudo service sendmail start有了sendmail的支持,就可以在php中用mail()函数发送邮件了。
PHP如何使用MAIL函数发邮件PHP mail 发送邮件
(PHP 4, PHP 5)
mail — 发送邮件
说明
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
发送一封电子邮件。
参数
to
电子邮件收件人,或收件人列表。
本字符串的格式必须符合 ? RFC 2822。例如:
user@example测试数据
user@example测试数据, anotheruser@example测试数据
User <user@example测试数据>
User <user@example测试数据>, Another User <anotheruser@example测试数据>
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 ( ).
关于php使用mail的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于php使用mail php使用函数限制字符串长度和格式的详细内容...