2

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)

Alana Storm
  • 164,128
  • 91
  • 395
  • 599
  • 2
    I would think your best bet is to grep for the email content or subject. They could be using an arbitrary external system call using backticks, which you'd have trouble finding. – zombat May 27 '10 at 00:41
  • Email is Dynamically generated from the database. – Alana Storm May 27 '10 at 01:46

5 Answers5

2

fsockopen is most likely the other one.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
2

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
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
1

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

  • Welcome to the site bob, it's better to consolidate all your answers under a single question than to post multiple answers. – Alana Storm May 27 '10 at 02:03
  • 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 May 27 '10 at 02:09
  • @Ignacio Discounting 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 May 27 '10 at 02:28
1

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
  • 1,961
  • 1
  • 13
  • 15
  • Not if the program is opening direct connections with a mail server on another computer. – Alana Storm May 27 '10 at 13:22
  • 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 May 28 '10 at 02:38
0

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

Marc Bollinger
  • 3,109
  • 2
  • 27
  • 32
  • 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. – Alana Storm May 27 '10 at 02:00
  • @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 May 27 '10 at 05:04
  • @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 May 27 '10 at 18:40