Enable Send Email in XAMPP (localhost)
In this tutorial, i will share how to send Email from XAMPP (PHP). i use XAMPP 1.8.1 version .This has been tested by me and it worked.
Lets start:-
first always make a backup before changing any code in core/configuration files.
then
---------------------------
[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
; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesD:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
;sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"
After Changes :-
-----------------------
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = yourgmailid@gmail.com
; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesD:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"
now
Lets start:-
first always make a backup before changing any code in core/configuration files.
then
Edit your php.ini in - “xampp\php\php.ini”
Before Changes:----------------------------
[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
; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesD:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
;sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"
After Changes :-
-----------------------
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = yourgmailid@gmail.com
; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesD:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"
now
Edit your sendmail.ini - “xampp\sendmail\sendmail.ini”
smtp_server=mail.mydomain.com or smtp_server=localhost
; smtp port (normally 25)
; smtp port (normally 25)
smtp_port=25
comment these two lines using - ;
;smtp_server=mail.mydomain.com or ;smtp_server=localhost
; smtp port (normally 25)
; smtp port (normally 25)
;smtp_port=25
and add some extra code in the bottom of your sendmail,ini:
;new config:
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=tls
error_logfile=error.log
pop3_server=
pop3_username=
pop3_password=
force_recipient=
hostname=
auth_username=yourgmailid@gmail.com
auth_password=your gmail password
force_sender=yourgmailid@gmail.com
NOTE:
- You Need to restart xampp after saving both files.
- Change yourgmailid@gmail.com & your gmail password with your own email id and password
- You Need to enable SMTP in your GMail to make this work and all sender will be from your email (if need).