tags:

views:

76

answers:

3

In my PHP program, I am having trouble with the mail() function.

I can call it in my scripts anywhere up until this line:

$this->db_conn = mysqli_connect($this->db_host, $this->db_user, $this->db_pass);

If I put a call to the mail function immediately before it, mail() succeeds and returns true. If I put mail() right after this line, mail() fails and returns false.

Why could this be happening?

EDIT: The rest of my script continues as normal after the mail() call. This wasn't an issue until recently. Is there some PHP/Apache setting that might have been changed?

EDIT2: Didn't notice it before, but there is indeed a Warning showing up:

PHP Warning:  mail() [<a href='function.mail'>function.mail</a>]: Could not execute mail delivery program '/usr/lib/sendmail -t -i'

What could mysqli_connect() be doing to prevent the mail program from functioning?

EDIT3: This is server is running Solaris with Apache web server. For now, I've switched PHPMailer over to using SMTP mode which is working fine. Still trying to figure out what is going wrong with mail() though.

A: 

Check your logs to see if it reports any reason for the mail() or database call to fail.

Jonathan Sampson
+1  A: 

The problem is almost certainly the database connection - check the connectionstring is working and maybe output something ( some trace data to do with those databas variables would be the obvious choice ) in the following line ahead of your mail() call to check what is going on and whether that is working.

The database log may let you know if you are having problems with credentials.

glenatron
+1  A: 

The web server may be running out of available file descriptors, or hitting its file descriptor limit.

Ignacio Vazquez-Abrams
I'm not entirely sure, but I'm pretty sure this was the issue.
Wickethewok