tags:

views:

23

answers:

2

Hi everyone!

I have like 50 different php files which all use the mail function. After all of this apparently the client doesn't want it to be from his [email protected] to be the default "from email address."

I've figured out that there is a "from" attribute which you can send with the mail function which can accomplish this, however if at all possible I don't really want to alter all these different pages. (Forgive me, I'm new to PHP and I know I should have put all these into one function so that I would only have to change that one, but live and learn I suppose!)

I've read that you can alter your php.ini file to change the default "from address" but I can't seem to find this file in the root directory! There isn't an etc dir either, but I know that it is a linux-based server and not windows.

Could I just upload a php.ini which changes the settings of the mail function only?

Any advice would be hugely appreciated, Thank you!

A: 

Consider using PHPMailer. It takes care of all these worries without requiring php.ini changes.

Download the version for PHP 5 and check out e.g. this question for an example how to use it.

Pekka
would this require me to include this class in each of pages? I believe it would, its ok, i might as well just include the from attribute in the mail function thanks anyway
Pete Herbert Penito
@Pete the class gives you a number of advantages over the classic "mail()" function because you can talk directly to a SMTP server, and do things like cc, bcc, attachments etc. conveniently. If you just need plain mailing functions, though, you may be fine with mail() alone.
Pekka
+1  A: 

The ini setting is called sendmail_from. Run phpinfo() to check which directory contains the php.ini.

webbiedave
hey mucho gracias webbiedave
Pete Herbert Penito
De nada. Glad I could help.
webbiedave