codepoet Posted November 23, 2009 Share Posted November 23, 2009 Can you please look at http://www.lifeatzion.com/christmasrsvp (you can test it if you like) It RANDOMLY decides, "yes, I'll send the email" or "no, I don't think I want to this time." I've had it.... So when you submit the form, it sends two emails---rather, sometimes it does. I've tried it before, and it'll work, then I try it again without changing anything, and it doesn't work. Help would be GREATLY appreciated here... hopefully I'm the one off my rocker and I'm just missing something. My code: <?php $hostname = $_POST['hostname']; $hostemail = $_POST['hostemail']; $onenames = nl2br($_POST['onenames']); $oneaddress = nl2br($_POST['oneaddress']); $twonames = nl2br($_POST['twonames']); $twoaddress = nl2br($_POST['twoaddress']); $threenames = nl2br($_POST['threenames']); $threeaddress = nl2br($_POST['threeaddress']); $fournames = nl2br($_POST['fournames']); $fouraddress = nl2br($_POST['fouraddress']); $fivenames = nl2br($_POST['fivenames']); $fiveaddress = nl2br($_POST['fiveaddress']); $iamatablehost = $_POST['iamatablehost']; if($iamatablehost == "on"){ $unix = time(); $message = "Review RSVP: http://www.lifeatzion.com/christmasrsvp/$unix.php"; mail('[email protected]', 'RSVP', $message); $subject = "Re: RSVP"; $message = '<html> <head> <title>RSVP</title> </head> <body bgcolor="#d9d5b7"> <center> <table width="600px;" bgcolor="#FFFFFF" style="padding:10px"> <tr> <td style="padding-bottom:10px;border-bottom:#06381e 2px solid;"><img src="http://www.lifeatzion.com/christmasrsvp/small-logo.png" /></td> </tr> <tr> <td style="padding-top:10px;"> <font family="Arial"> Dear '.$hostname.', <p>This is a confirmation email. We have received your RSVP\'s and will process them shortly. Your RSVP\'s are as follows:</p> <p> In Christ, <p> Life at Zion Events Team<br /> [email protected] </td></tr></table> </center> </body> </html>'; // multiple recipients $to = $hostemail; // 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: Host <'.$to.'>' . "\r\n"; $headers .= 'From: Life at Zion Events Team <[email protected]>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); $guestone = <<<HTML <fieldset><legend><big><b>Guest (or Guest Family) #1</b></big></legend> <table style="width:100%;"> <tr><td style="width: 150px;" valign="top">Guest(s) #1 Name(s):</td> <td>$onenames</td></tr> <tr><td style="width: 150px;" valign="top">Guest(s) #1 Mailing Address:</td> <td>$oneaddress</td></tr> </table></fieldset> HTML; if($twonames !== ""){ $guesttwo = <<<HTML <br /><br /><fieldset><legend><big><b>Guest (or Guest Family) #2</b></big></legend> <table style="width:100%;"> <tr><td style="width: 150px;" valign="top">Guest(s) #2 Name(s):</td> <td>$twonames</td></tr> <tr><td style="width: 150px;" valign="top">Guest(s) #2 Mailing Address:</td> <td>$twoaddress</td></tr> </table></fieldset> HTML; } else { $guesttwo = ""; } if($threenames !== ""){ $guestthree = <<<HTML <br /><br /><fieldset><legend><big><b>Guest (or Guest Family) #3</b></big></legend> <table style="width:100%;"> <tr><td style="width: 150px;" valign="top">Guest(s) #3 Name(s):</td> <td>$threenames</td></tr> <tr><td style="width: 150px;" valign="top">Guest(s) #3 Mailing Address:</td> <td>$threeaddress</td></tr> </table></fieldset> HTML; } else { $guestthree = ""; } if($fournames !== ""){ $guestfour = <<<HTML <br /><br /><fieldset><legend><big><b>Guest (or Guest Family) #4</b></big></legend> <table style="width:100%;"> <tr><td style="width: 150px;" valign="top">Guest(s) #4 Name(s):</td> <td>$fournames</td></tr> <tr><td style="width: 150px;" valign="top">Guest(s) #4 Mailing Address:</td> <td>$fouraddress</td></tr> </table></fieldset> HTML; } else { $guestfour = ""; } if($fivenames !== ""){ $guestfive = <<<HTML <br /><br /><fieldset><legend><big><b>Guest (or Guest Family) #5</b></big></legend> <table style="width:100%;"> <tr><td style="width: 150px;" valign="top">Guest(s) #5 Name(s):</td> <td>$fivenames</td></tr> <tr><td style="width: 150px;" valign="top">Guest(s) #5 Mailing Address:</td> <td>$fiveaddress</td></tr> </table></fieldset> HTML; } else { $guestfive = ""; } $appspg = <<<HTML <html> <head> <title>RSVP</title> <style> body { background: #d9d5b7; margin: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; } td { font-weight:bold; font-size: 12px; padding-bottom: 10px; } td input, textarea { border: #000 1px solid; font-family: Arial; font-size: 14px; padding: 5px; } textarea { width: 400px; height: 150px; } </style> </head> <body> <div style="background:#FFF;margin:0px auto;width:700px;padding: 20px;"> <div style="background: url('rsvp-mcc-logo.png') no-repeat;text-align:right;height:79px;padding-bottom:10px;border-bottom: #06381e 2px solid;"> <img src="online-rsvp-header.png" style="padding-top:40px;" /> </div> <h2>RSVP #$unix</h2> <form name="form" action="approve.php" method="post"> <p> <h2>Host Details</h2> <table style="width:100%;"> <tr><td style="width: 150px;">Host Name:</td> <td>$hostname</td></tr> <tr><td style="width: 150px;">Host Email:</td> <td>$hostemail</td></tr> </table> </p><br /> <p> <h2>Guest Details</h2> $guestone $guesttwo $guestthree $guestfour $guestfive </form> </div> </body> </html> HTML; $fp = fopen($unix.'.php', 'w'); fwrite($fp, $appspg); fclose($fp); echo "<h2>Thank you, $hostname! We will email you shortly with table information for your guests. If you need to RSVP more guests, <a href=\"index.php\">click here.</a></h2>"; } else { echo "<h2>You must be a Table Host to submit this form. Please call 434-245-8986 if you are not a Table Host, or return to the previous page and check the \"I am a Table Host\" checkbox."; } ?> Link to comment https://forums.phpfreaks.com/topic/182585-php-mail-randomly-sending/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.