views:

110

answers:

5

I'm looking for a list of built in PHP functions that a programmer could use to send an email.

The obvious answer here is mail(), but I'm also looking for a list of functions someone might use to manually open a connection to an MTA, or spawn a process on the local machine which might in turn send an email using sendmail, postfix, etc.

The context here is I want to scan a large, unknown codebase for code that's sending out email (because we already located a call to mail(), and that's not doing it)

+2  A: 

fsockopen is most likely the other one.

Col. Shrapnel
+1  A: 

IMAP may be another depending on how PHP was configured... http://www.php.net/manual/en/ref.imap.php

bob_the_destroyer
Welcome to the site bob, it's better to consolidate all your answers under a single question than to post multiple answers.
Alan Storm
Thanks. I know, but being new and unregistered, I don't have permission to include more than one url or comment under any other answer.
bob_the_destroyer
@IgnacioDiscounting the imap_mail() function, actually, these functions open and work on an IMAP stream to any supporting local or remote service, from my understanding. As well as regular mailbox administration, this function family behaves as if it simply inserts a message into any mailbox. From there, it could conceivably be sent out by the mail server if in some type of queue.
bob_the_destroyer
A: 

Just looking at the mail() docs, it looks like Pear::Mail would be a good candidate, or at least better.

Marc Bollinger
But Pear::Mail would end up needing to use some internal PHP mechanism to implement its functionality. There's probably hundreds of third party mailing libraries out there.
Alan Storm
@Alan Storm Sure, but scanning the codebase wouldn't necessarily find PEAR's usage of the `mail` function if it's included from somewhere else on the system.
ceejayoz
@ceejayoz Hmph. In this case, it does: http://svn.php.net/viewvc/pear/packages/Mail/trunk/Mail.php?view=markup @Alan StormHave you been able to ferret out what the actual problem with `mail()` is? I'd suspect that many of the hundreds of third party mailing libraries open sockets to the MTA in the same way `mail()` does.
Marc Bollinger
+1  A: 

And as well as the backtick, also check for popen() and system execution functions... http://us2.php.net/manual/en/ref.exec.php

exec
passthru
proc_close
proc_get_status
proc_open
proc_terminate
shell_exec
system
` 

IMAP may be another depending on how PHP was configured... http://www.php.net/manual/en/ref.imap.php

   fsockopen is most likely the other one
bob_the_destroyer
+1  A: 

Sneaky way would be to turn off your local mail service and check your php error logs for the sendmail errors you get :)

This should stop php from being able to send emails locally

Thomas Winsnes
Not if the program is opening direct connections with a mail server on another computer.
Alan Storm
that's why I said locally :) In any case, there is always an IP in the email header, so you can see which server the email was sent from. So just turn off the email service on that server and look for errors. Or even just block the email port from the host with php using iptables.
Thomas Winsnes