• We just launched and are currently in beta. Join us as we build and grow the community.

How to Setup Google SMTP in XAMPP (php.ini and sendmail.ini)

lpyro

Profitable Side Hustler
L Rep
0
0
0
Rep
0
L Vouches
0
0
0
Vouches
0
Posts
53
Likes
183
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
xampp-google-smtp-banner.jpg


In this tutorial, I will show you how to Set Up XAMPP Sendmail Service using Google SMTP. The tutorial aims to provide the students with a reference on how they can set up a mailing server using their local machine. Here, I will use the Google App Password Feature for the mailing service authentication.

What is Sendmail in XAMPP?

Sendmail is one of the inbuild packages in XAMPP. It is used for sending mail locally or as a mailing service of the local apache. For example, you have a simple PHP Project with a mailing feature, to use the PHP mail() function, we use the sendmail package to send mail from localhost.

What is SMTP?

SMPT stands for Simple Mail Transfer Protocol. It is an Internet communication protocol for sending electronic mail.SMTP is a protocol that allows mail servers and other message transfer agents to send and receive mail messages. It manages email transmission via an SMTP server.

What is Google/Gmail SMTP?

Gmail SMTP is a free SMTP (Simple Mail Transfer Protocol) that anyone can use. You can use email clients or web applications to manage email transactions from your Gmail account. Email clients are mail programs used by users. The most well-known ones include Mac Mail, Outlook, and Thunderbird.

How Set Up Google/Gmail SMTP in XAMPP Sendmail Service?

Here are the following steps that you need to do to implement Gmail SMTP as the mailing server of your XAMPP to send mail in localhost.

Step 1: Create an Account

The first thing you must do is create a Google Account.

Step 2: Generate an App Password in your Google Account

Next, you need to generate an App Password in your Google Account. The generated google account will be used for authentication which means you can set the XAMPP sendmail service mailing authentication variables without using your actual Google Account Password. To do that, follow the instruction below.

  • Go to Google Account
    xampp-sendmail-google-smtp-google-1.jpg

  • Navigate the page to "Security" page and enable/set up your account with 2-Step Verification to enable App Password Feature.
    xampp-sendmail-google-smtp-google-2.jpg

  • Next, generate an App Password that you will use for XAMPP sendmail package.
    xampp-sendmail-google-smtp-google-3.jpg

  • Then, copy/paste the generated App Password in a secure location for later use.
    xampp-sendmail-google-smtp-google-4.jpg


Step 3: Set up XAMPP (php.ini) Mail Function

Open your XAMPP php.ini

(i.e. "D:\xampp\php\php.ini") file with your preferred text editor and find the mail function settings using the [mail function] keyword. Then, change the settings like the following:

SMTP=smtp.gmail.com

smtp_port=465 b

sendmail_from = [email protected] br

sendmail_path = "D:\xampp\sendmail\sendmail.exe -t -i"

xampp-sendmail-google-smtp-php-ini.jpg


Step 4: Set up the XAMPP Sendmail Configuration (sendmail.ini)

Next, configure the XAMPP's sendmail (i.e. "D:\xampp\sendmail\sendmail.ini") package with Gmail SMTP using your Google Account.

smtp_server=smtp.gmail.com

smtp_port=465

smtp_ssl=auto

error_logfile=error.log

auth_username[email protected]

auth_password=zxcasdqwe1

xampp-sendmail-google-smtp-sendmail-ini.jpg


Step 5: Restart your Apache

Lastly, don't forget to restart your XAMPP's Apache server if it is already running or started.

There you go! Your XAMPP is now ready to send mail using localhost. To test that you use the following PHP script.

  1. <?php
  2. /**
  3. * Sample Sending Mail Script using PHP Mail
  4. */

  5. try{
  6. mail

    (

    "[email protected]"

    ,

    "Sample Mail Only"

    ,

    "This is a sample email content only"

    )

    ;
  7. echo

    "Email Message sent!"

    ;
  8. }

    catch(

    Exception $e

    )

    {
  9. print

    (

    $e

    ->

    getMessage

    (

    )

    )

    ;
  10. }

Browse or execute the example PHP script on your end to send a sample mail to your Gmail. Don't forget to change [email protected]

to the email address you want to receive the sample mail.

That's it! I hope this How to Setup Google SMTP in XAMPP (php.ini and sendmail.ini) Tutorial will help you with what you are looking for and will be useful for you for developing your current and future web projects.

Explore more on this website for more Tutorials and Free Source Codes.

Happy Coding =)

 

442,401

317,942

317,951

Top