Home >Backend Development >PHP Tutorial >How Can I Successfully Send Emails from XAMPP Localhost Using Gmail's SMTP Server?
Despite sending emails from localhost using the PHP mail() function, some users may encounter issues where emails are not received at the intended destination. This article addresses these difficulties by outlining a specific solution involving the implementation of "fake sendmail" and the necessary configurations.
Step 1: Installation of "Fake Sendmail for Windows"
Download and install "fake sendmail for windows" to bridge the communication gap between PHP and the SMTP server.
Step 2: PHP.ini Configuration
Adjust the php.ini file to specify the use of sendmail:
[mail function] ; For Win32 only. ; SMTP = smtp.gmail.com ; smtp_port = 25 ; For Win32 only. ; sendmail_from = <e-mail username>@gmail.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
Step 3: "sendmail.ini" Configuration
Configure the "sendmail.ini" file with the following settings:
[sendmail] smtp_server=smtp.gmail.com smtp_port=25 error_logfile=error.log debug_logfile=debug.log auth_username=<username> auth_password=<password> force_sender=<e-mail username>@gmail.com
Step 4: Two-Factor Verification
For Gmail accounts protected by two-factor authentication, generate and utilize an application-specific password to access the account via PHP.
The above is the detailed content of How Can I Successfully Send Emails from XAMPP Localhost Using Gmail's SMTP Server?. For more information, please follow other related articles on the PHP Chinese website!