p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: sendmail and mail() problems


Message #1 by "Eric Amidon" <eamidon@s...> on Mon, 7 Oct 2002 21:25:01
Some of my clients have been getting "hung-up" while waiting for a reply 
from the sendmail server. Here is the code as it is written:

+++++++++++++++++++++++++++++

  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 am thinking about doing is adding an "else" to this to have it show 
the "confirmation page" if it receives no answer from the sendmail server. 
My question is how to do that if the command doesn't return FALSE like it 
says on page 516 of the book?

Any help would be greatly appreciated.
Message #2 by jfernando@c... on Mon, 7 Oct 2002 21:38:47
I'm fairly new to PHP, but I think you have to have \r\n to separate the
extra header information string and at the end of it too. (Or maybe is just
in the Win32 platform). Therefore:

if (defined('SEND_EXTRA_ORDER_EMAILS_TO')) { 
    mail(SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, 
         message, 'From: ' . $customer_values['customers_email_address']);
}

Should be:

if (defined('SEND_EXTRA_ORDER_EMAILS_TO')) { 
    mail(SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, 
         message, 'From: ' . $customer_values['customers_email_address']
.'\r\n');
}


That's all I can see.

  Return to Index