General

How to Send Mail from Localhost XAMPP Using Gmail

Hello Magento Pals?,

How are you all developing? Many of my blog readers have written me up for an illustration on How to Send Mail from Localhost XAMPP Using Gmail. In this article, I will help you all to solve How to Send Mail from Localhost XAMPP Using Gmail stepwise. Also. go through our latest article How to Manage Out of Stock Notification in Magento 2. Let’s Dive In?

Introduction:

Basically XAMPP stands for [X] Cross-Platform, [A] Apache, [M] MariaDB, [P] PHP and [P] Perl. It is mainly used by all the developers for creating all the local web servers in order to test and deploy the projects. When we think of online business project testing then it always includes a test case where the developers need to send emails for testing purposes. For sending that email with the help of XAMPP via Gmail you require to configure XAMPP after the installation. Apply the below steps for configuring Gmail in localhost XAMPP.

How to Send Mail from Localhost XAMPP Using Gmail?:

Step 1: Firstly begin with opening the XAMPP Installation Directory.

Step 2: Navigate to C:\xampp\php and open the php.ini file.

Step 3: Search for (mail function) with the help of ctrl + f.

Step 4: Find and pass the given below values:

SMTP=smtp.gmail.com

smtp_port=587

sendmail_from = YourGmailId@gmail.com

sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”

Step 5: After this navigate to  C:\xampp\sendmail and open sendmail.ini file.

Step 6: Search for (sendmail) with the help of ctrl + f.

Step 7: Find and pass the given below values:

smtp_server=smtp.gmail.com

smtp_port=587

error_logfile=error.log

debug_logfile=debug.log

auth_username=YourGmailId@gmail.com

auth_password=Your-Gmail-Password

force_sender=YourGmailId@gmail.com(optional)

Script To Send Mail?:

<?php

$toemail = "receiver_email@gmail.com";

$subject = "Test Email";

$body = "Hi, This is test email send by PHP Script";

$headers = "From: sender\'s email";




if (mail($toemail, $subject, $body, $headers)) {

    echo "Email successfully sent to $toemail...";

} else {

    echo "Email sending failed...";

}

That’s It you are done.

Final Words:

Hopefully, all are able to Send Mail from Localhost XAMPP Using Gmail. If any queries tell me in the comment box below. Help others in sending Mail from Localhost XAMPP Using Gmail. by sharing this article. 

Happy Mailing?

Click to rate this post!
[Total: 22 Average: 3]
Gaurav Jain

Gaurav Jain is Co-Founder and Adobe Certified Expert-Magento Commerce Business Practitioner. Being Computer Engineer👨‍💻 and possessing Extensive Marketing skills he handles all kinds of customer Queries and his Happy😀 & Helping🙏 Nature makes customer's day Delightful. When he isn’t working, you’ll find Gaurav Reading on Books📖 or Traveling🚗. Also, he is Speaker at Magento Meetups.

View Comments

  • Warning: mail(): Failed to connect to mailserver at "gmail.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

    I have followed all your steps, checking both .txt ini files and still have failed connection

  • : mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. a23sm1709372vkl.32 - gsmtp in

  • <?php

    $toemail = "receiver_email@gmail.com";

    $subject = "Test Email";

    $body = "Hi, This is test email send by PHP Script";

    $headers = "From: sender\'s email";

    if (mail($toemail, $subject, $body, $headers)) {

        echo "Email successfully sent to $toemail...";

    } else {

        echo "Email sending failed...";

    }

    where want paste this code

    • You need to create the PHP testing file into the Xampp root directory where you run your other projects.

  • Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\usertable\controllerUserData.php on line 33

    I follow every instructions but it appears like this

    • I think the code which you have implemented miss-match the starting and ending quote ("). So please verify your code one's at line no: 16

Recent Posts

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

7 hours ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

3 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

3 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

3 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

4 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

6 days ago