My mail script has recently stopped working for no apparent reason (Damn 1&1) and I was hoping someone could help me out... PHP is not my strong point.
Basically people fill in an online form, select the download links they want sending via a checkbox system and they receive an email that provides them with the links and a quick message, also copying in me so that I can see who has downloaded the files and what they've had.
<?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{
?>
Side note: I am aware I could use a separate php script to check the validity of the info provided but this has served me ok up until now.