PHP mail()函数服务器和localhost不工作 [英] PHP mail() function server and localhost not working

查看:224
本文介绍了PHP mail()函数服务器和localhost不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



mail('myemail@gmail.com','新订单,订单详细信息);



该代码在我的xampp本地主机或服务器上不起作用。 (我没有收到任何电子邮件)。
我读过关于必须在我的服务器上编辑php.ini文件,但它似乎允许(基于我的微不足道的知识)。



[邮件功能]
sendmail_path = / usr / local / bin / sendmail -oi -t





我的主要目标是能够在我的实际网站上发送。 (不要担心实际本地主机)

解决方案

您需要确保电子邮件From地址是有效的地址存在于您的服务器上 - 请参阅我的答案。



验证电子邮件PHP



您需要在 mail(); - 您似乎缺少 - 请参阅



PHP邮件表单不工作



添加一个Reply-To:标题,并使用您的电子邮件地址从您的用户那里获取,以便您收到一封电子邮件,您可以回复,而不是默认访问您的服务器。



其他有用的评论:
PHP邮件因为某些原因不起作用



我个人最喜欢的解决方案也被其他人推荐:PHPMailer https://github.com/PHPMailer/PHPMailer


I am trying to send a simple email on one of my web pages.

mail('myemail@gmail.com', 'NEW ORDER', 'order details');

The code does not work on my xampp localhost, nor my server. (i received no emails). I read about having to edit a php.ini file on my server, but it seemed to allow it (based on my minuscule knowledge).

[mail function] sendmail_path = /usr/local/bin/sendmail -oi -t

Any ideas?

My main goal is to be able to send it on my actual website. (im not as worried about the actual localhost)

解决方案

You need to ensure that the email "From" address is a valid address which exists on your server - see my answers among others

Authenticate Email PHP

And you need a "From" on your mail(); - which you appear to be missing - see

PHP mail form isn't working

Add a "Reply-To:" header and use the email address which you get from your user in that, so that you receive an email which you can reply to rather than it defaulting to going to your server.

Other useful comments: PHP mail not working for some reason

My personal favourite solution also recommended by plenty of others: PHPMailer https://github.com/PHPMailer/PHPMailer

这篇关于PHP mail()函数服务器和localhost不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆