原标题:php发邮件测试
例如:php发邮件,下面是phpmailer通过sendmail发送邮件简单测试例子。
$Name = "system engineer"; //发件人
$email = "email@email.com"; //发件邮箱
$recipient = "a_test_account@qq.com"; //收件邮箱
$mail_body = "The text for the test mail by engineer.."; //邮件body
$subject = "Subject for reviever"; //邮件subject
$header = "From: ". $Name . " ";
mail($recipient, $subject, $mail_body, $header); //mail命令
?>
将以上内容保存为test.php
执行/www/wdlinux/php/bin/php test.php
查看收件是否收到邮件,如果收不到,请检查sendmail是否正常,以及sendmail和php.ini中关于Mail模块的配置
下面列出检查方式:
查看sendmail服务是否正常:/etc/init.d/sendmail status 如果是running则运行正常,如果不对,则start或者restart下,看提示进行下一步操作
检查php.ini中关于mail模块的配置:
[mail function]
; For Win32 only.只在win环境中才启用
;SMTP = localhost
;smtp_port = 25
; For Win32 only.只在win环境中才启用
;sendmail_from = test@test.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").只在Unix环境中才使用
sendmail_path = /usr/sbin/sendmail -t -i返回搜狐,查看更多
责任编辑: