Behavior of mail() function
Behavior of mail() function
am 19.04.2010 21:22:08 von Lewis Kapell
Running PHP version 5.3.1, I find that if my script tries to send an
email message to an address in the local domain, and the address is
invalid, mail() throws an error:
mail(): SMTP server response: 550 5.1.1 :
Recipient address rejected: User unknown in local recipient table
Is there a way I can configure PHP so that mail() would return false in
this case, rather than throwing an error which causes the script to die?
Our mail server is a Linux server running Postfix, if that matters.
Thank you
Lewis Kapell
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Behavior of mail() function
am 19.04.2010 21:25:55 von Venkat Raman Don
You can use PHP exception to handle it and the script will not die. Details=
at http://php.net/manual/en/language.exceptions.php.
Thanks,
Don.
-----Original Message-----
From: Lewis Kapell [mailto:lkapell@setonhome.org]=20
Sent: Monday, April 19, 2010 12:22 PM
To: php-windows@lists.php.net
Subject: [PHP-WIN] Behavior of mail() function
Running PHP version 5.3.1, I find that if my script tries to send an email =
message to an address in the local domain, and the address is invalid, mail=
() throws an error:
mail(): SMTP server response: 550 5.1.1 :=20
Recipient address rejected: User unknown in local recipient table
Is there a way I can configure PHP so that mail() would return false in thi=
s case, rather than throwing an error which causes the script to die?
Our mail server is a Linux server running Postfix, if that matters.
Thank you
Lewis Kapell
--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http:=
//www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Behavior of mail() function
am 19.04.2010 21:39:26 von Pierre Joye
hi,
On Mon, Apr 19, 2010 at 9:22 PM, Lewis Kapell wrote:
> Running PHP version 5.3.1, I find that if my script tries to send an email
> message to an address in the local domain, and the address is invalid,
> mail() throws an error:
>
> mail(): SMTP server response: 550 5.1.1 : Recipient
> address rejected: User unknown in local recipient table
>
> Is there a way I can configure PHP so that mail() would return false in this
> case, rather than throwing an error which causes the script to die?
The script should not die. Mail returns false (no exception are
raised) on failure and can raise warnings. These warnings can be
disable using the http://www.php.net/error_reporting ini settings
(works per directory, per script or globally per php.ini).
Cheers,
--
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Behavior of mail() function
am 20.04.2010 16:15:27 von Lewis Kapell
After testing more carefully I see what is happening. The call to
mail() is generating a warning, and our custom error handler is trapping
that and causing the script to abort.
Thanks for setting me in the right direction.
Thank you,
Lewis Kapell
Computer Operations
Seton Home Study School
On 4/19/2010 3:39 PM, Pierre Joye wrote:
> hi,
>
> On Mon, Apr 19, 2010 at 9:22 PM, Lewis Kapell wrote:
>> Running PHP version 5.3.1, I find that if my script tries to send an email
>> message to an address in the local domain, and the address is invalid,
>> mail() throws an error:
>>
>> mail(): SMTP server response: 550 5.1.1: Recipient
>> address rejected: User unknown in local recipient table
>>
>> Is there a way I can configure PHP so that mail() would return false in this
>> case, rather than throwing an error which causes the script to die?
>
> The script should not die. Mail returns false (no exception are
> raised) on failure and can raise warnings. These warnings can be
> disable using the http://www.php.net/error_reporting ini settings
> (works per directory, per script or globally per php.ini).
>
> Cheers,
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php