hi there.
i have the following PHP mail form (below). my intention is to do basic validation then send 2 emails 1) to me to add the user to a list 2) a confirmation email to the person who subscribed.
if i use only the top 'mail' line:
mail($emailTo, $subject, $message, "From: $email");
i get only one email sent (as expected). if i use only the bottom 'mail' line:
mail($email, $subject, $message1, "From: Soccer Club <news@aclub.com>" );
the recipient receives the same email twice (duplicated) - not what is intended. if i use both 'mail' lines both recipients receieve duplicate emails.
here is my full code. any help would be appreciated. i want each recipient to receive only one email.
<?php
//test if a dropdown item is selected AND checkbox selected or not
// Handle POST method.
if ($POST)
{
$email = $POST['email'];
// Compose simple text message:
$message = "Message from $name ($email)\n\nAdditional Notes:\nMessage sent to Webmaster\nAdd to adelaidevillasc.com email list";
$message1 = "Subsciption confirmation $name ($email)\n\nThank you for subscribing to Soccer Club's weekly news and match reports\n\nThis is an automated response.\nPlease do not reply to this email message.";
$emailTo = "webmaster@club.com";
$subject = "Email Subscription to club.com";
// Send message
if ((empty($email)) || ($email == "your email address")){ //test if email blank or contains default text
echo "Use you browser's back button to re-enter your email address";
}else{
//add to email list note
mail($emailTo, $subject, $message, "From: $email");
//email subscription confirmation to subscriber
mail($email, $subject, $message1, "From: Soccer Club <news@club.com>" );
// Thank the user
echo "Thank you for subscribing";
}
}
else
{
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
Weekly match reports<br />
<input type="text" onFocus="this.value=''" name="email" value="your email address"/>
<p><input type="submit" value="Subscribe" /></p>
</form>
<?php
}
?>