Page 1 of 1

Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 00:54
by sandyMN
I have XAMPP installed and have been running PHP apps on my windows vista machine for several months now. However, I can't send any emails through my PHP apps. I understand that I need to set up Mercury, which I believe I have done through the XAMPP control panel. However, I can't seem to find a way to set up my SMTP settings. Is there a file I need to alter in order to do this? Also, host requires authentication when sending emails, and I can't see a way to do this either. Thanks in advance for the help!

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 01:00
by Izzy
Missing support info - what XAMPP version?

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 01:12
by sandyMN
XAMPP 1.7.2

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 01:30
by Izzy
Look in \xampp\php for the php.ini file and open in your text editor.

Find this section
Code: Select all
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"C:\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 =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\apache\logs\php_mail.log"
Change it so it looks like this, then save the file and restart Apache
Code: Select all
[mail function]
; For Win32 only.
; http://php.net/smtp
; SMTP = localhost
; http://php.net/smtp-port
; smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\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 =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\apache\logs\php_mail.log"
Next go to \xampp\sendmail folder and load the sendmail.ini file in your text editor.
Code: Select all
# Example for a user configuration file

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# Mercury
account Mercury
host localhost
from postmaster@localhost
auth off

# A freemail service example
account Hotmail
tls on
tls_certcheck off
host smtp.live.com
from [exampleuser]@hotmail.com
auth on
user [exampleuser]@hotmail.com
password [examplepassword]

# Set a default account
account default : Mercury
Edit this file by adding your own details and credentials.

You can use the freemail section by changing the details and credentials and also the name or comment it out fully including the Mercury stuff but use it as a template for your own ISP account (best to use your ISP account to avoid ISP blocking of email ports), I advise not to use Mercury Mail unless you have a full blown LAN in use - you would need also to change the default account name to suit your edits.

There are some posts that a search in XAMPP for Windows using sendmail or email as the keywords may find that could be helpful and informative on this subject.

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 02:02
by sandyMN
The email is not sending, but I am no longer receiving an error message, so I think it's really close. I believe I need to specify my port, which is NOT port 25. Is that done somewhere in the sendmail.ini file as well? Thanks for all of your help...

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 02:19
by Izzy
sandyMN wrote:I believe I need to specify my port, which is NOT port 25. Is that done somewhere in the sendmail.ini file as well?
Add port followed by the number after the auth on entry.
For example
Code: Select all
auth on
port 465

Remember that these [ ] brackets are only example containers and should never be included in any of the final configuration entries.

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 02:27
by sandyMN
Still not sending the emails. This is what I have in sendmail.ini (sensitive info is hidden):

# Example for a user configuration file

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# Mercury
account Mercury
host localhost
from postmaster@localhost
auth off

# A freemail service example
account Hotmail
tls on
tls_certcheck off
host smtp.mydomain.net
from [email@mydomain.com]
auth on
port 465
user [my user name]
password [my password]


# Set a default account
account default : Mercury

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 02:42
by Izzy
sandyMN wrote:Still not sending the emails. This is what I have in sendmail.ini (sensitive info is hidden):

# Example for a user configuration file

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# Mercury
account Mercury
host localhost
from postmaster@localhost
auth off

# A freemail service example
account Hotmail
tls on
tls_starttls off
tls_certcheck off
host smtp.mydomain.net
from [email@mydomain.com]
auth on
port 465
user [my user name]
password [my password]


# Set a default account
account default : Hotmail
Change the red entries:
to account default : Hotmail

and add this after tls on
Code: Select all
tls_starttls off

Any entries in the sendmail.log file in the sendmail folder?

You read my above comment about the [ ] brackets?
There should be no such brackets in any of the final settings.

This topic covered many issues that were finally solved by removing the [ ] brackets from around the OP's password:
viewtopic.php?f=16&t=37643

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 03:07
by sandyMN
Hi. I just put the brackets there so you could see what I was indicating. There are no actual brackets in the file itself. It also appears that I do not have a sendmail.log file. Maybe because no email was actually sent and the file wasn't created?

account default : Hotmail

My SMTP host is Comcast, so would I use the following?
account default : Comcast

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 05:13
by Izzy
sandyMN wrote:It also appears that I do not have a sendmail.log file. Maybe because no email was actually sent and the file wasn't created?
The sendmail.log would be created if the script you are using actually found sendmail and used it.

If sendmail fails to send the mail then it will create the sendmail.log file and give you feedback on the reason it failed to send.

So logically your script is not finding sendmail as your sendmail.ini file below looks to be in order and should function correctly.

Your sendmail.ini file is also currently setup to use TLS on port 465 but I notice that ComCast also uses port 587 instead of port 25 for sending SMTP without TLS, so it is possible to use either but not mixed - only use port 465 with tls entries and port 587 with no tls entries
Code: Select all
# A freemail service example
account Comcast
tls on
tls_starttls off
tls_certcheck off
host smtp.comcast.net
from [email@comcast.net]
auth on
port 465
user [my user name]
password [my password]

# Set a default account
account default : Comcast
You can obviously send and receive mail from your email client in the normal manner and sendmail when configured with your email credentials works in a similar manner to send the mail.

Re: Sending email through PHP/XAMPP ... how is this set up?

PostPosted: 29. December 2009 15:06
by sandyMN
Okay - I replaced sendmail.ini with the last code you posted. At least I think that's what you wanted me to do :lol:

Still no email. I think I'm getting ready to give up. I've been a ColdFusion programmer for years and setting up an email server is so simple ... I just can't figure out what I'm doing wrong with PHP - it's not supposed to be rocket science, right? :(