Page 1 of 1

using php mail() function on localhost w/ xampp

PostPosted: 28. April 2009 23:05
by programguru
Hello, :?:

I am just trying to test my php email scripts w/ php mail() before I upload them to my live server, and I wanted to know if anyone can suggest a working tutorial on properly configuring the php.ini to use the mail() function on localhost.

Thank you for a advice :

Re: using php mail() function on localhost w/ xampp

PostPosted: 29. April 2009 00:50
by Sharley
Now there are different locations for the php.ini file to edit depending on which version of XAMPP you are using - always a good idea to give the XAMPP version and the OS you are using so we can provide a related reply.

Re: using php mail() function on localhost w/ xampp

PostPosted: 29. April 2009 01:02
by programguru
Hi Sharley,

Here is the that info: ApacheFriends XAMPP (Basispaket) version 1.6.8

OS: Win XP Home SP2

Re: using php mail() function on localhost w/ xampp

PostPosted: 29. April 2009 01:18
by Sharley
OK, that really helps.

Open xampp\apache\bin\php.ini file in your text editor and find the section:
Code: Select all
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "\xampp\sendmail\sendmail.exe -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
Edit it so it looks like this but replace the red text with your own details usually the same as you use in your email client like OE etc.:
[mail function]
; For Win32 only.
SMTP = mail.myisp.com
smtp_port = 25

; For Win32 only.
sendmail_from = me@myisp.com <-- uncomment this line

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "\xampp\sendmail\sendmail.exe -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

Please let me know back if that helped you send your mail via your script.
Thanks.

Re: using php mail() function on localhost w/ xampp

PostPosted: 29. April 2009 04:40
by programguru
Sharley,

Thank you for the advice. I will try this, but I am using a test gmail account, and was wondering if the configuration is different or more data is required?

Re: using php mail() function on localhost w/ xampp

PostPosted: 29. April 2009 04:58
by Sharley
If you are required to provide a username/password combination to access an SMTP server then you can't use the above method.

Instead you would comment out the "for Win32 only" section and uncomment the sendmail_path line.

Then you need to edit the xampp\sendmail\sendmail.ini file with the details required and tell your script to use sendmail in it's configuration.

An advanced XAMPP for Windows forum search for keyword sendmail (or gmail perhaps - 90 posts to look through) will give many post that show the sendmail.ini file edits if you have problems trying to work out what is required.

Re: using php mail() function on localhost w/ xampp

PostPosted: 29. April 2009 05:06
by programguru
OK Sharley,

Thanks for your advice. I am going to search the forum for some details on that.