Page hanging up using mail() with sendmail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
sgt_underpants
Forum Newbie
Posts: 9
Joined: Mon Oct 07, 2002 11:52 am
Location: Denver
Contact:

Page hanging up using mail() with sendmail

Post by sgt_underpants »

I know that mail() doesn't return false and I'm looking for a workaround here. I have some users who are getting a white page while the script is waiting for the confirmation from sendmail that the mail was received and sent. Is there any way to avoid this problem of there is no reply? I'm new to PHP and whereas I understand the concepts of mail() I don't know the solution to my problem. Any help would be greatly appreciated.
sgt_underpants
Forum Newbie
Posts: 9
Joined: Mon Oct 07, 2002 11:52 am
Location: Denver
Contact:

Okay, so maybe my question was too idiotic to be answered...

Post by sgt_underpants »

...then let me elaborate more. This is what I learned in the WROX book entitled "Beginning PHP4" about the mail() function:
The function returns TRUE when it successfully passes the given mail message to the local mail system. It doesn't care whether the message has actually been sent. Unfortunately, the command doesn't return FALSE on failure - it just doesn't return at all, freezing execution of the script, and meaning the browser simply doesn't receive a response.
Okay, with that said here is my dilemma again. Some users have had this happen when wanting to confirm their order. The page is blank and the lil' icon in the corner just spins round 'n' round. :wink:

Here is the code as it is written:

Code: Select all

mail($customer_valuesї'customers_email_address'], EMAIL_TEXT_SUBJECT, $message, 'Content-Type: text/plain; charset="iso-8859-15"' . "\n" . 'Content-Transfer-Encoding: 8bit' . "\n" . 'From: ' . EMAIL_FROM);

// send emails to other people
  if (defined('SEND_EXTRA_ORDER_EMAILS_TO')) {
    mail(SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $message, 'From: ' . $customer_valuesї'customers_email_address']);
  }
  
// send email to customer service
  if (defined('SEND_CS_ORDER_EMAILS_TO')) {
    mail(SEND_CS_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $cs_message, 'From: ' . $customer_valuesї'customers_email_address']);
  }
What I would like to do is add code that would return the confirmation page even if it doesn't receive a response from the sendmail server. I hope that's a better explanation and that it warrants a response this time. :roll:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Locked