Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, how can I set php's mail() function to use smtp authentication?

I have a web server and then an mail server. All company's email, incoming or outgoing, passes through the mail server and I was wondering how to set the web server to use mail() function with SMTP authentication at the mail server.

Note: I need to do this globally, not to go file by file that runs the mail function in each site and start editing.

share|improve this question
up vote 4 down vote accepted

PHP's built-in mail() function does not expose functionality to make SMTP auth possible.

You would need to re-write existing code to use something like the PEAR Mail package.

Otherwise you may find it easier to set up a router on your web server's SMTP daemon to forward all outgoing mail to the mail server. In Exim, for example, this is accomplished with a smart_route definition.

share|improve this answer
these are my two only options? – w0rldart Feb 2 '12 at 21:53
I'm sure there are other alternatives including writing your own mail function wrapper, but the built-in mail() function, on its own, has no way of doing what you are describing. – Garrett Feb 2 '12 at 23:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .