send mail in php from localhost

Send mail in php  is possible to mail in php from localhost and it is a 100% working solution. there is a package code send mail in your Xampp

 

send mail in php from localhost
   send mail in php from localhost

Follow the steps to send mail in php from localhost

To send mail in php the First thing is you need to configure exam to send mail, let’s do that!.

Step 1: Send mail in php from localhost

Go to XAMMP folder and configure the following file.
C:\xampp\php\php.ini and c:\xampp\sendmail\sendmail.ini for gmail to send mail.

Inside C:\xampp\php\php.ini file find extension=php_openssl.dll and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.

Step 2: Send mail in php from localhost

Inside php.ini file find mail related keywords and change

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

Step 3: Send mail in php from localhost

Now Open C:\xampp\sendmail\sendmail.ini. Replace all the existing code in sendmail.ini with below code

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com

Setup is almost done.

Step 4: Send mail in php from localhost
Create the php file and paste the following code.

<?php
$message = mail(“xxx@xmail.xxx”,”Testing”,”Test Mail from localhost using PHP”);
echo “—“.$message.”—“;
if ( $message ) {
echo “The email has been sent!”;
} else {
echo “The email has failed!”;
}
?>
Note: Replace my-gmail-id and my-gmail-password in above code. Also, Remove the duplicate keys if you copied settings from above. For example comment following line if there is another sendmail_path : sendmail_path=”C:\xampp\mailtodisk\mailtodisk.exe” in the php.ini file

Also remember to restart the server using the XAMMP control panel so the changes take effect.

Step 5: Send mail in php from localhost

send mail in php from localhost
    send mail in php from localhost

Make your gmail account as Less Secure using this link https://myaccount.google.com/lesssecureapps.

Entire setup is almost completed if you have any queries feel free to comment below.

1 thought on “send mail in php from localhost”

  1. I was very delighted to locate this site on bing.I wished to say many thanks to you with regard to this good post!! I certainly loved every little bit of it and I’ve you bookmarked to have a look at new stuff you post

Leave a Reply

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