canditer Posted July 4, 2012 Share Posted July 4, 2012 I am really frustrated here, i have been working with the same email code(HTML Form submits fields to email) for awhile now and it has never given me a problem like this. what happens is the emails are sent but sometimes they are not sent. It is like there is a problem at the sever maybe, maybe thge sever switches on and off at times while people are filling in the form. The other scary part is that there are actually two email that are sent, one to the user and the other to the project manager for that form. So when a test was being conducted the user got the confirmation email but the project manager did not get the email. what could cos this? Here is the code <?php function customError($errno, $errstr,$error_file,$error_line,$error_context) { echo "<b>Error:</b> [$errno] $errstr on line $error_line<br />"; die(); } set_error_handler("customError"); $Email2 = $_POST["Email"]; $to = "[email protected]" ; $to2 = $Email2; $from = "[email protected]"; $headers = "From: $from" . "\r\n" . $subject = "2012 Registration"; $body = ""; $body2 = "Thank you for your registration."."\r\n"." Your invoice will be send to you within 48hours."."\r\n"; while (list($key,$value) = each($_POST)){ $body .= sprintf("%s: %s\r\n",$key,$value); } $send = mail($to, $subject, $body, $headers); $send2 = mail($to2, $subject, $body2, $headers); if(!$send) {print "We encountered an error sending your mail, please notify [email protected]";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/265190-php-email-send-and-sometimes-it-does-not-send/ Share on other sites More sharing options...
anevins Posted July 4, 2012 Share Posted July 4, 2012 What executes $send2? Quote Link to comment https://forums.phpfreaks.com/topic/265190-php-email-send-and-sometimes-it-does-not-send/#findComment-1359067 Share on other sites More sharing options...
anevins Posted July 4, 2012 Share Posted July 4, 2012 Also you could include a carbon copy within the same mail function Quote Link to comment https://forums.phpfreaks.com/topic/265190-php-email-send-and-sometimes-it-does-not-send/#findComment-1359068 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.