Home > Backend Development > PHP Tutorial > Why Aren't My XAMPP Localhost Emails Sent via Gmail Using PHP's mail() Function?

Why Aren't My XAMPP Localhost Emails Sent via Gmail Using PHP's mail() Function?

DDD
Release: 2024-12-16 12:26:10
Original
307 people have browsed it

Why Aren't My XAMPP Localhost Emails Sent via Gmail Using PHP's mail() Function?

Sending Email from XAMPP Localhost Using GMAIL via PHP

Issue: Difficulty sending emails from localhost using PHP's mail() function, despite successful return messages.

Configuration:

  • XAMPP with fake sendmail installed
  • PHP.ini settings:

    • sendmail_path = "C:xamppsendmailsendmail.exe -t"
  • sendmail.ini settings:

    • smtp_server = smtp.gmail.com
    • smtp_port = 25
    • auth_username = [GMAIL username]
    • auth_password = [GMAIL password]

Solution:

  1. Install fake sendmail for Windows.
  2. Modify php.ini to utilize fake sendmail as follows:
[mail function]
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
Copy after login
  1. Configure sendmail.ini as specified in the above settings.
  2. If using a Gmail account with 2-factor verification, create an application-specific password for email sending.

By following these steps, you can successfully send emails from localhost using XAMPP and the GMAIL mail server.

The above is the detailed content of Why Aren't My XAMPP Localhost Emails Sent via Gmail Using PHP's mail() Function?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template