我使用php 5.3.13,pear mail和google captcha(recaptcha)来创建一个简单的"联系我们"表单.
有一个电子邮件字段,一个主题字段和一个注释字段.用户也解决了验证码,然后他可以按"发送".
这在我的笔记本电脑本地工作正常,而不是在我安装网站的服务器上.它完全相同的代码.
我使用简单的Gmail和smtp
服务器,我的大学服务器.有两个文件,contact
包含表单并contactsend
获取数据并发送它们.他们来了
联系
contactsend
is_valid) {header('Location:contact.php?cc=1'); exit();} //else send mail else { $email = "mymail@gmail.com"; $message = $comment; $from = $maila; $to = "mymail@gmail.com"; $subject = $subj; $body = $message; $host = "ssl://smtp.server.address"; $username = "aaaa"; $password = "00000"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject, 'Content-Type' => "text/plain; charset=\"UTF-8\"", 'Content-Transfer-Encoding' => "8bit" ); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password, 'port' => '465' ) ); $mail = $smtp->send($to, $headers, $body); //if there is an error while sendig mail, send back if (PEAR::isError($mail)) {header('Location:contact.php?ce=1'); exit();} //if success while sending mail, send back else {header('Location:contact.php?co=1'); exit();} } ?>
当我以简单用户身份访问网站时,我收到HTTP 500错误.我不知道如何解决这个问题.有什么建议?
谢谢
编辑
在我放置我的网站的服务器上,我安装了PEAR和Mail.是一个Windows Server 2012 R2和PHP 5.3.13.现在,一位朋友告诉我编辑,php.ini
这样就可以了.我编辑了这个
[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = ssl://smtp.uwg.gr ; http://php.net/smtp-port smtp_port = 465 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = culturalmapupatra@gmail.com
还有这个
;***** Added by go-pear include_path=".;C:\Program Files (x86)\PHP\PEAR\Mail"
但仍然没有运气.我错过了什么?
太感谢了