Enable PHP mail(...) Function on XAMPP for Windows
How to Configure mailtodisk.exe in the php.ini Configuration File
Configure mailtodisk.exe
The mailtodisk.exe is included in the XAMPP installation,
so you don't need to download or install any additional components.
mailtodisk.exe:
"A win32 executable in the PHP environment as sendmail dummy for writing
emails on local-disk."
Folders:
- In the following instructions we assume that XAMPP was installed in the C:\xampp directory.
- You will find the outgoing mails as text files in <xampp>\mailoutput
e.g. C:\xampp\mailoutput.
You should delete the files in the "mailoutput" directory from time to time, as the directory can be a maximum of 300 MB in size.
If the size is exceeded, no more files will be saved.
Edit php.ini Configuration
1. Open the php.ini located in C:\xampp\php and search
for the section: [mail function]
e.g.
[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 = me@example.com
; For Unix only. You may supply arguments
as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
; 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().
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that
will include uid of the script followed by the filename
mail.add_x_header=On
; The path to a log file that will
log all mail() calls. Log entries include
; the full path of the script,
line number, To address and headers.
;mail.log =
; Log mail to syslog
(Event Log on Windows).
;mail.log = syslog
2. Comment out "SMTP=..." and "smtp_port=..."
e.g.
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP=localhost
; http://php.net/smtp-port
;smtp_port=25
Important: If you haven't commented out the two lines, it won't work.
3. Set the sendmail path to mailtodisk.exe and set the
default "sender" email address
e.g.
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP=localhost
; http://php.net/smtp-port
;smtp_port=25
sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
sendmail_from=me@example.com
4. Optional: Set the logfile path
e.g.
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP=localhost
; http://php.net/smtp-port
;smtp_port=25
sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
sendmail_from=me@example.com
mail.log="C:\xampp\mailoutput\php_mail.log"
5. After these changes, the [mail function] section should look something like this:
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP=localhost
; http://php.net/smtp-port
;smtp_port=25
sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
sendmail_from=me@example.com
mail.log="C:\xampp\mailoutput\php_mail.log"
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; For Unix only. You may supply arguments
as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
; 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().
;mail.force_extra_parameters
=
; Add X-PHP-Originating-Script: that will include uid of the script
followed by the filename
mail.add_x_header=On
; The path to a log file that will log
all mail() calls. Log entries include
; the full path of the script,
line number, To address and headers.
;mail.log =
; Log mail to syslog
(Event Log on Windows).
;mail.log = syslog