Pear Mail - Trap for errors?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all.

I have some Pear Mail code composing an email and sending it to an external smtp server for sending. 

The issue is determining whether that external server actually accepted the mail or not.  In the IF(PEAR… code below, it will return success even if I leave the $to value empty.  However, if I remove the smtp username or password, it will return an error indicating it could not reach the remote server.  So the Pear::IsError function seems to only reflect if the intended server was accessible… and not if the intended server accepted the outgoing email for delivery.

Anyone have experience with the scenario below… specifically with determining if the smtp server accepted the mail for delivery?

Thanks for any info.

--Rick






 require_once "Mail.php";
 
 $from = "from@xxxxxxxxxxx";
 $to = "to@xxxxxxxxxxx";
 $subject = "Hello!";
 $body = "Hello!";
 
 $host = "mail.host.net";
 $username = "myuser";
 $password = "mypass";
 
 $headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
 $smtp = Mail::factory('smtp',array ('host' => $host,'auth' => true,'username' => $username,'password' => $password));
 
 $mail = $smtp->send($to, $headers, $body);
 
 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Message successfully sent!</p>");
  }
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux