How To: PHP Sendmail and XAMPP on Windows
(2009-11-27 16:05:42)
标签:
phpxamppit |
分类: 网络技术 |
It can be difficult getting the PHP’s default mail functions to
work when you run an apache server on windows instead of a unix
environment.
First, ensure that you have an XAMPP release that does include
the fake sendmail program. [More details here]
Next, go to the XAMPP directory (often C:\xampp\), then open the
’sendmail’ subdirectory.
sendmail.exe
readme.html
sendmail.ini
sendmail_example.ini
license.html
Open the file sendmail.ini – this is where all of your SMTP server
configurations will go, for example: SMTP Username, Password, Host,
Port, etc
My sendmail.ini file looks something like this:
; configuration for fake sendmail
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=465
; SMTPS (SSL) support
;
;
;
;
smtp_ssl=auto
default_domain=brettshaffer.com
error_logfile=error.log
; if your smtp server requires authentication, modify the following
two lines
auth_username=<USERNAME / EMAIL ADDRESS
HERE>
auth_password=<PASSWORD HERE>
Note that this is a very simple setup.
GMail requires an SSL connection, so my config was setup to use SSL
port 465 and smtp_ssl=auto.
Once the configuration is setup, make sure to save changes, then
exit.
If you are going to use SSL connections, you will need two
additional files, available here (as of March 2009) – if this link no longer
works, use the contact form and let me know.
Extract the two compressed files (libeay32.dll and ssleay32.dll) to
the same directory as sendmail.exe (for me,
C:\xampp\sendmail\)
Now, everything on the sendmail’s end is setup – now we just need
to let the server know its there!
Edit your PHP.ini file:
XAMPP installations often have multiple files.
Look for the following line:
sendmail_path = “C:\xampp\sendmail\sendmail.exe -t”
Uncomment the line (if already commented) by removing the semicolon
at the start.
Ensure that the path to sendmail.exe is correct (this is correct
for me).
Save and exit php.ini
Restart the apache server and everything should
work!
http://brettshaffer.com/blog/how-to/php-sendmail-and-xampp-on-windows/