简体   繁体   English

PHP 500内部服务器错误-邮件功能

[英]PHP 500 Internal Server Error- mail function

I'm getting the 500 Internal Server Error. 我收到500内部服务器错误。 I called goDaddy and they told me it's not something on their end. 我打电话给goDaddy,他们告诉我这不是他们的目的。 I also don't have a .htaccess file. 我也没有.htaccess文件。 I checked the contact page and checked spelling it is calling the right .php file. 我检查了联系页面,并检查了拼写是否正在调用正确的.php文件。

This code was working perfectly. 该代码运行良好。 I tried to change something it didn't work. 我试图更改无效的内容。 I tried going back to the original code and now that doesn't work either. 我尝试回到原始代码,但现在也不起作用。 I don't have a backup. 我没有备份。 I commented out line by line to pin-point the problem if I erase the mail($to, $subject, $message, $headers); 我逐行注释掉了如果我清除mail($to, $subject, $message, $headers);的问题mail($to, $subject, $message, $headers); part I don't get an error but obviously don't receive anything. 部分,我没有收到错误,但显然什么也没收到。 Here is the website if that helps to inspect. 如果可以帮助检查,请访问以下网站。

http://www.crownjewelre.com/contacts.html http://www.crownjewelre.com/contacts.html

  <?php

$first_name    = $_POST['first_name'];
$last_name    = $_POST['last_name'];
$email    = $_POST['email'];
$telephone    = $_POST['telephone'];
$comments    = $_POST['comments'];


// multiple recipients
$to  = 'michaelgaraysi@yahoo.com' . ', '; // note the comma


// subject
$subject.= "CrownJewelRe question From: ".$first_name." ".$last_name. "\n";

// message
$message = "
<html>
<head>
  <title>Contact Information</title>
</head>
<body>
  <table>
    <tr>
      <td>Name:  </td><th>".$first_name."</th><th>".$last_name."</th>
    </tr>
    <tr>
      <td>Email:  </td><th>".$email."</th>
    </tr>
    <tr>
      <td>Telephone:  </td><th>".$telephone."</th>
      </tr>
      </table>
      <br><br>
       <p>Comments: &nbsp;  <strong>".$comments."</strong></th>



</body>
</html>
";

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

try to change, 尝试改变

$to  = 'michaelgaraysi@yahoo.com' . ', ';

to

$to  = 'michaelgaraysi@yahoo.com';

and

$subject.= "CrownJewelRe question From: ".$first_name." ".$last_name. "\n";

to

$subject= "CrownJewelRe question From: ".$first_name." ".$last_name. "\n";

and finally, try to run this simple php mailer script, and then apply your changes, 最后,尝试运行此简单的php mailer脚本,然后应用您的更改,

<?php
$to      = 'michaelgaraysi@yahoo.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: birthday@example.com' . "\r\n" .
'Reply-To: birthday@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

?> ?>

like the others $subject.= is auto-expand of a non existing var but that not the problem here :) 像其他$ subject。=是不存在的var的自动展开,但这不是问题所在:)

1st : have you tested a blank page with only the function mail : 第一:您是否仅使用邮件功能测试了空白页:

mail ('michaelgaraysi@yahoo.com','test','message corpus');

if its working its not a missconfig of youre PHP. 如果它的工作不是您的PHP的missconfig。

2nd : How can you use in 2015 the mail function, its have a high spam rate, instead use https://github.com/PHPMailer/PHPMailer or other. 第二:2015年如何使用邮件功能,它具有较高的垃圾邮件率,而是使用https://github.com/PHPMailer/PHPMailer或其他。

I think it will solve your problem or maybe you just need to remove the "\\n"; 我认为这可以解决您的问题,或者您只需要删除“ \\ n”即可; on $subject :) 在$ subject :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM