PHP邮件脚本停止工作

时间:2017-04-04 10:56:03

标签: php arrays email

我的邮件脚本最近停止工作没有明显的原因(该死的1& 1)我希望有人可以帮助我... PHP不是我的强项。

基本上人们填写在线表格,通过复选框系统选择他们想要发送的下载链接,他们会收到一封电子邮件,为他们提供链接和快速信息,同时也会复制我,以便我可以看到谁下载了文件和他们拥有的东西。

<?php
$email = $_POST ["from"]  ;

if ( isset ( $_POST [ 'buttonPressed' ] )){
if ( array_search('', $_POST) ) {
  echo "<p><font color='red'>You must fill in all required fields, please <a href='http://mywebsite.com/downloads/access.php'>try again</a></font></p>"; 
  exit; 
} 

if( empty($_POST['cb']) ) { echo "<p><font color='red'>You must select a download by using the checkboxes on the left, please <a href='http://www.mywebsite.com/Downloads/access.php'>try again</a></font></p>";
  exit; 
 }
else 
{ 
 }

if (preg_match('/@/', $email))
{
}
else
{
  echo "<p><font color='red'>You must enter a valid email, please <a href='http://www.mywebsite.com/Downloads/access.php'>try again</a></font></p>"; 
  exit; 
}

if (preg_match('/\./', $email))
{
}
else
{
  echo "<p><font color='red'>You must enter a valid email, please <a href='http://www.mywebsite.com/Downloads/access.php'>try again</a></font></p>"; 
  exit; 
}

$checkbox = implode( "\r\n" . "\r\n" , $_POST['cb'] ); 


// REPLACE THE LINE BELOW WITH YOUR E-MAIL ADDRESS.
$to = $_POST["from"];
$subject = 'WEBSITE - mywebsite Downloads' ;

// NOT SUGGESTED TO CHANGE THESE VALUES
$message = "Dear" ." ". $_POST ["name"] ."\n". "Thank you for visiting mywebsite.com, we look forward to dealing with " . $_POST ["companyName"]." in future." ."\n"."\n" . "If there is anything further that you need, we would be delighted to arrange one of our technical representatives to call you." . 
"\n"."\n".
"Please find your download link below:"."\n"."\n".     

"$checkbox" .


"\n"."\n". "Please do not reply to this email, all replies in relation to this email should be sent to person@mywebsite.com"
 ;
$headers = 'From: no-reply@mywebsite.com ' . PHP_EOL ;   "\r\n";
$headers .= 'Bcc: person1@mywebsite.com, person2@mywebsite.com ' . "\r\n";
mail ( $to, $subject, $message, $headers ) ;


echo "<p><font color='green'>A download link has been sent to $to</font></p>"; }

else{
?>

旁注:我知道我可以使用单独的php脚本来检查所提供信息的有效性,但直到现在这已经很好了。

0 个答案:

没有答案