PHP表单提交但没有电子邮件 [英] PHP form submit but no email

查看:89
本文介绍了PHP表单提交但没有电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您的耐心等待。我看了很多论坛都没有用。

我有一个简单的表格html / php,供访问者发送问题。

表格在第1页,提交转到页面,回显表单,然后重定向到index.php。表单会获取数据,并在第2页上发布,但收件箱和垃圾邮箱中没有收到任何电子邮件。我将第2页上的所有内容都缩减回

展开 | 选择 | Wrap | 行号

解决方案

你有< a href =http://bytes.com/topic/php/answers/629295-read-first-turn-php-debugging-messages\"target =_ blank>错误消息是否已开启?


我的第一个猜测是,这是因为你没有指定 From 标题。需要指定邮件功能才能工作,无论是在PHP配置中还是使用它的第四个参数。


请参阅邮件功能的手动输入。尝试添加与您的代码类似的内容,看看是否有效。


Atli,是的,谢谢,我尝试过,没有区别。

我的直觉是php.ini文件正在停止发送邮件,我不能编辑它,也不能让webhost编辑它。


确定。如果您没有权力更改配置,并且邮件功能似乎没有正确配置,您可以尝试使用其中一个邮件程序类。 PHPMailer Swift Mailer 过去对我来说效果很好。


有了它们,即使你的服务器没有提供sendmail或SMTP服务器,你可以让他们使用外部程序。他们甚至可以使用Gmail SMTP服务器。 (但要小心.Gmail不适用于群发邮件。)


Thank you for your patience. I have looked at numerous forums to no avail.
I have a simple form html/php, for visitors to send questions.
The form is on page 1, which submits to page to, echoes the form and then redirects to index.php. The form picks up the data, and posts it on page 2 , but no email arrives in the inbox nor junk box. I whittled everything on page 2 back to

Expand|Select|Wrap|Line Numbers

解决方案

Do you have the error messages turned on?

My first guess would be that this is because you do not specify the From header. It needs to be specified for the mail function to work, either in the PHP config or using it''s fourth parameter.

See the second example in the manual entry for the mail function. Try to add something similar to your code and see if that works.


Atli, yes thanks, I have tried that, no difference.
My gut feeling is that the php.ini file is stopping the send mail, and I can''t edit this, nor get the webhost to edit it either.


Ok. If you have no power to alter the config, and the mail function doesn''t seem to be configured properly, you could try to use one of the mailer classes. Both PHPMailer and Swift Mailer have worked well for me in the past.

With them, even if your server does not provide a sendmail or SMTP server, you can have them use an external program. They can even be made to use the Gmail SMTP server. (Be careful though. Gmail is not meant for mass-mailing.)


这篇关于PHP表单提交但没有电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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