php sendmail path,图文介绍Apache+PHP服务器环境中配置sendmail.exe使用mail()函数

这篇博客介绍了如何通过sendmail结合SMTP服务器(例如smtp.sina.com.cn)在本地实现邮件发送。配置涉及修改php.ini和sendmail.ini文件,包括设置SMTP服务器地址、端口、认证用户名和密码。作者提供了sendmail的下载链接,并给出了使用mail()函数的PHP代码示例。此外,还提到了在虚拟主机环境中进行的额外配置。
摘要由CSDN通过智能技术生成

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

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

我的sendmail.exe放在D:\sendmail\下

在php.ini中只填写 sendmail_path

[mail function]

; For Win32 only.

;SMTP = smtp.163.com

;smtp_port = 25

; For Win32 only.

;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").

sendmail_path = "D:\sendmail\sendmail.exe -t"

就配置三项,smtp,smtp_port和sendmail_path

sendmail.ini配置

[sendmail]

//现在的163不能用smtp发邮件了,只好转其他的smtp服务器

; you must change mail.mydomain.com to your smtp server

smtp_server=smtp.sina.com.cn

smtp_port=25

auth_username=yourusername

auth_password=yourpassword

force_sender=yourusername@sina.com

sendmail网上有下的,地址是:http://glob.com.au/sendmail/

如果你是用xampp,那里面直接就带了。

不过此种方法,查看收到的邮件头,会是两个发件人。

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

php_admin_value sendmail_path 'd:\sendmail\sendmail.exe -t yourusername@sina.com'

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

配置好后,自己在php文件中用mail()函数就可以在本机发邮件了,如果还有问题,请联系我哦,kunga0814@sina.com

mail()函数部分:

if (mail ( $send_to, $send_subject, $send_content, $headers )) {

echo "发送给{$send_to}的邮件成功!";

} else {

echo "发送给{$send_to}的邮件失败!";

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值