1

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.

3
  • Did you check your logs? Commented Dec 31, 2009 at 0:44
  • Sorry for my ambiguous pronouns - as I corrected above, it is the "mail()" function that is failing; the database connection seems fine. Commented Dec 31, 2009 at 0:51
  • I assume the path to sendmail is correct? I guess if the line works in one place but not in another then you're almost certainly fine. But why then does it not work in one circumstance and work in another? Is there anything in the sendmail logs? Commented Jan 2, 2010 at 0:20

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I'm not entirely sure, but I'm pretty sure this was the issue.
1

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.