Home  >  Article  >  php教程  >  PHP用mail或pear mail发送邮件(window/linux)

PHP用mail或pear mail发送邮件(window/linux)

WBOY
WBOYOriginal
2016-05-25 16:49:161170browse

本文章来给各位同学介绍一下PHP用mail或pear mail发送邮件(window/linux),有需要了解学习的同学可进入参考哈

一 、windows sendmail

http://glob.com.au/sendmail/

二、windows smtp 服务器

http://msdn.microsoft.com/zh-cn/library/8b83ac7t(v=vs.80).aspx

解决 WIN7 SMTP 安装问题,有人说WIN7系统没有SMTP服务 怎么可能呢,具体安装步骤如下:控制面板/程序>打开和关闭Windows功能,Internet信息服务  将 万维网服务>应用程序开发功能>.NET扩展性 勾上 安装 就可以了.

php mail()函数在windows不能用

php mail()函数在windows不能用,需要安装sendmail。Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in

1.从http://glob.com.au/sendmail/下载sendmail.zip

2.解压到C:下,例如C:/PHP/sendmail,最好短路径,长路径名有可能产生问题。

3.修改php.ini如下

sendmail_path = "C:/PHP/sendmail/sendmail.exe -t"

4.根据你自己的配置环境修改sendmail.ini。

第一次最好启用debug.log_file,error_logfile,以查看sendmail是否生效。

5.重启apache

用sendmail结合其它的smtp服务器,如smtp.airmb.com来实现发邮件。现在大部分邮箱都要求smtp验证,所以要在sendmail.ini中加入用户名和密码。

php.ini配置 (以用airmb.com邮箱为例)

[mail function]  
; For Win32 only.  
SMTP = smtp.airmb.com  
smtp_port = 25  
; For Win32 only.  
sendmail_from = facai@airmb.com  
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").  
sendmail_path = "C:/PHP/sendmail/sendmail.exe -t"

就配置三项,smtp、smtp_port和sendmail_path

sendmail.ini配置

[sendmail]   
; you must change mail.mydomain.com to your smtp server  
smtp_server=smtp.airmb.com  
smtp_port=25  
auth_username=yourusername  
auth_password=yourpassword  
force_sender=facai@airmb.com  
; default_domain=mydomain.com

同时在虚拟主机的conf里加上这样一句

php_admin_value sendmail_path  'C:/PHP/sendmail/sendmail.exe -t facai@airmb.com'

此邮件地址为用户的邮件地址,随便添。

注意,经测试,结果如下 : 发送成功 ,表示已发到邮件服务器队列!但邮件服务器没有启动!

运行: service sendmail start

另外 ,已发送成功的邮件,sendmail服务器会一直保存 ! 启动邮件服务器后 ,所有未发送的都会发送.

教程链接:

随意转载~但请保留教程地址★

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn