RE: [PHP] override built-in mail()
| From: | Hansen, Mike | Date: | Fri, 04 Feb 2011 20:42:44 +0000 |
| Subject: | RE: [PHP] override built-in mail() | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311151@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Thijs Lensselink [mailto:dev@lenss.nl]
> Sent: Friday, February 04, 2011 12:48 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] override built-in mail()
>
> On 02/04/2011 08:44 PM, Thijs Lensselink wrote:
> > On 02/04/2011 08:38 PM, Steve Staples wrote:
> >> On Fri, 2011-02-04 at 20:25 +0100, Thijs Lensselink wrote:
> >>> On 02/04/2011 04:59 PM, Steve Staples wrote:
> >>>> On Fri, 2011-02-04 at 07:51 -0800, Jim Lucas wrote:
> >>>>> On 2/4/2011 5:37 AM, Steve Staples wrote:
> >>>>>> Hello Guys/Gals,
> >>>>>>
> >>>>>> it's friday (at least where I am it is) and I have an
> issue with a
> >>>>>> script that I just started using again. The problem
> is, is that it uses
> >>>>>> the built in PHP mail() function, and on my testing
> server, mail()
> >>>>>> doesn't work. The other issue, is that I use SMTP Auth
> to connect to my
> >>>>>> mail server, so that when mail sends out, it comes
> from my mail server
> >>>>>> so that there is less of a chance for being marked as SPAM.
> >>>>>>
> >>>>>> So, what I am looking to do, is use either the trust
> old Pear::Mail or
> >>>>>> PHPMailer scripts (I am sure there are other ones out
> there, but those
> >>>>>> are the 2 I am most familiar with).
> >>>>>>
> >>>>>> So now to my actual question. How can I override the
> built-in PHP
> >>>>>> mail() function, to let either of those 2 (or
> something else someone may
> >>>>>> suggest) to act in the same manner as the mail() function?
> >>>>>>
> >>>>>> Is this easy? I've googled, but haven't seen any
> reference to doing
> >>>>>> what I am looking to do (maybe I just can't google)
> >>>>>>
> >>>>>> Steve
> >>>>>>
> >>>>>>
> >>>>>
> >>>>> You cannot "override" a function. You will have to
> write a new function,
> >>>>> "my_mail" or some such. Have it take the same
> arguments as the built in mail
> >>>>> function, but internally it uses phpmailer or the
> likes. Then, do a search and
> >>>>> replace for " mail(" with " my_mail("
> >>>>>
> >>>>> One other possible option, which I had not contemplated
> until now, would be to
> >>>>> actually specify a replacement sendmail executable when
> setting up the sendmail
> >>>>> option in the php.ini. You could specify a php script
> that can run as though it
> >>>>> was sendmail, accept the same arguments, etc... but do
> all the phpmailer stuff
> >>>>> inside.
> >>>>>
> >>>>> Jim Lucas
> >>>>>
> >>>>
> >>>> after posting this, and doing some more googleing, I found this:
> >>>>
> >>>> http://ca.php.net/manual/en/function.override-function.php
> >>>>
> >>>> it says you can override built-in php functions... I
> haven't tested to
> >>>> see if i can do it, but it seems possible... has anyone used this
> >>>> before? and will it do what I need? (this has been put
> on the back
> >>>> burner for today, so tonight I will look more deeper
> into this unless
> >>>> someone else has any luck in the mean time)
> >>>>
> >>>> TIA!
> >>>>
> >>>> Steve
I would opt for using my_mail and not overriding a built-in function. It seems to me that it would
just cause confusion for the next developer who takes care of your code. You know, that psychopathic
programmer that knows your address. =)