Home » Send Mail From Localhost in PHP Using XAMPP

Send Mail From Localhost in PHP Using XAMPP

Send Mail From Localhost in PHP Using XAMPP, Firstly, PHP is an open-source scripting language, which means where you can change your PHP core files according to your requirements.

PHP also has a SENDMAIL inbuilt package, which is used to send mail from a localhost server like XAMPP.

Send Mail From Localhost in PHP Using XAMPP

The below process explained from the XAMPP server.

XAMPP stands for:

  • Cross-Platform -X
  • Apache -A
  • MySQL -M
  • PHP -P
  • Perl -P

4+ Steps to Send Mail From Localhost in PHP Using XAMPP

Here are list of all the steps which I explained below completely.

  • Create an APP password to setup Gmail SMTP.
  • Modify [mail function] on the PHP config file (php.ini).
  • Modify [mail function] on the SendMail config file (sendmail.ini).
  • Restart Apache server.
  • Try the example source code.

Create an APP password to setup Gmail SMTP

To access Gmail account which is protected by 2Step Authentication we have to create APP password which helps to send mail using our Gmail account as SMTP account.

Create APP password on Gmail

Then you get the password like “woaablyvvycyznenv” this. Keep it safe for further.

Modify [mail function] on the PHP config file (php.ini)

  • Go to this location: C:\XAMPP\php\php.ini
  • Open php.ini file on any text editor and search [mail function]

Changes on [mail function] on php.ini file

Remove semicolon (;) first on below lines, and put the given changes,

SMTP=smtp.gmail.com
smtp_port=465
sendmail_from = yourGmailID@gmail.com
sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”

Modify [mail function] on the SendMail config file (sendmail.ini)

  • Now next is the Open Sendmail configuration file named sendmail.ini.
  • path: c:\xampp\sendmail\sendmail.ini

search [mail function]

Changes on [mail function] on sendmail.ini file

  • smtp_server=smtp.gmail.com
  • smtp_port=465
  • smtp_ssl=auto
  • error_logfile=error.log
  • debug_logfile=debug.log
  • auth_username=writeyourgmail@gmail.com
  • auth_password=PUTthecreatedAppPasswordOnFirstStep

Restart the APACHE Server on XAMPP control panel.

Example of Send Mail From Localhost in PHP Using XAMPP

These are the complete steps for sending mail from localhost in PHP.

Also, Check:

Media Query CSS for Desktop, Tablet, Mobile

Happy Coding..!

2 thoughts on “Send Mail From Localhost in PHP Using XAMPP”

  1. Pingback: jQuery Contact Form Send Email Using Ajax - PHPCODER.TECH

Leave a Reply

Your email address will not be published. Required fields are marked *