# Is it possible to override internal function?

- Thread: https://externals.io/message/15806
- Original archive: https://news-web.php.net/php.internals/15806
- Started by Piotr Roszatycki on 2005-04-05T07:56:47+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #15806 — Piotr Roszatycki — 2005-04-05T07:56:47+00:00

URL: https://externals.io/message/15806#15806

I'd like to create PECL module which could replace `mail()` function. The new 
function would use SMTP protocol. I can't call any external utilities so this 
is the only posibility to send the mails. The environment is shared hosting 
platform so there are some limits, like forbidding the calling suid-ed 
binaries (like /usr/sbin/sendmail) and low number of user processes.

This have to be hidden implementation so the users won't need to change their 
code, especially calling of `mail()` function.

Is it possible to override the internal function in additional module?

-- 
 .''`.    Piotr Roszatycki, Netia SA
: :' :    mailto:Piotr_Roszatycki@netia.net.pl
`. `'     mailto:dexter@debian.org
  `

---

## #15808 — Johannes Schlueter — 2005-04-05T08:52:05+00:00

URL: https://externals.io/message/15806#15808 · In reply to: #15806

Hi,

the funxtions are stored in the EG(function_table) hash table. So you could
delete or rename the mail function from there and add a new one. 

APD has an override_function() and a rename_function() which can be used to
replace/rename a function by a user defined one. Maybe the code of these
help you a bit.

http://lxr.php.net/source/pecl/apd/php_apd.c#608

For this being successfull it's important that your extension is loaded
after the standard extension.

Even though this works I doubt that you can can rely on it. (stability,
changing APIs, ...)

johannes

Piotr Roszatycki wrote:

> I'd like to create PECL module which could replace `mail()` function. The
> new function would use SMTP protocol. I can't call any external utilities
> so this is the only posibility to send the mails. The environment is
> shared hosting platform so there are some limits, like forbidding the
> calling suid-ed binaries (like /usr/sbin/sendmail) and low number of user
> processes.
> 
> This have to be hidden implementation so the users won't need to change
> their code, especially calling of `mail()` function.
> 
> Is it possible to override the internal function in additional module?
> 

-- 
Johannes Schlüter                           Mayflower GmbH / ThinkPHP
http://thinkphp.de                            http://blog.thinkphp.de
