THAPA TECHNICAL

HOUSE OF WEB DEVELOPERS AND TECHNOLOGY.

How to send mail from localhost XAMPP using PHP

How to send mail from localhost XAMPP using PHP


To send mail from localhost XAMPP using Gmail, configure XAMPP after installing it. Follow the below steps for the same.

Steps to Send Mail From Localhost XAMPP Using Gmail:

Open XAMPP Installation Directory.


Go to C:\xampp\php and open the php.ini file.
Find [mail function] by pressing ctrl + f.
Search and pass the following values:
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = YourGmailId@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"


Now, go to C:\xampp\sendmail and open the sendmail.ini file.

Find [sendmail] by pressing ctrl + f.
Search and pass the following values
smtp_server=smtp.gmail.com
smtp_port=587 or 25 //use any of them
error_logfile=error.log
debug_logfile=debug.log
auth_username=YourGmailId@gmail.com
auth_password=Your-Gmail-Password
force_sender=YourGmailId@gmail.com(optional)

Here is the actual code that you have to write
Script To Send Mail:

<?php
$to_email = "receipient@gmail.com";
$subject = "Simple Email Test via PHP";
$body = "Hi, This is test email send by PHP Script";
$headers = "From: sender email";

if (mail($to_email, $subject, $body, $headers)) {
    echo "Email successfully sent to $to_email...";
} else {
    echo "Email sending failed...";
}



**Note: If you are getting a warning message then Please configure “Less secure apps” settings as shown below. Sometimes without turning on the 'less secure apps' is the main reason the user didn't receive the mail.

=> Turning on 'less secure apps' settings as mailbox user

Go to your (Google Account).
On the left navigation panel, click Security.
On the bottom of the page, in the Less secure app access panel, click Turn on access.
If you don't see this setting, your administrator might have turned off less secure app account access (check the instruction above).
Click the Save button.

** Now your email will be sent successfully. Have a good day and please share your story in the comment box.

87 comments:

  1. helo bhai user aur admin panal ki vidio banawo app ki sari vidio dekhat hu lekin app abhi tak admin panell par vidio nahi banaye

    ReplyDelete
  2. hello sir mere xamp server pe php.ini sho nahi kar raha hai please reply

    ReplyDelete
  3. Email send ho raha hai local host pe par receiver pe nhi aa raha hai

    ReplyDelete
    Replies
    1. Email successfully sent to javalight86@gmail.com...
      successfully ka message ata he but mail send nahi hota?

      Delete
    2. send path mein -t se pehle space hai "\"C:\xampp\sendmail\sendmail.exe\" -t"

      Delete
  4. hi,
    please make a video with multiple email attachement

    ReplyDelete
  5. sir as a shop ak website please a video

    ReplyDelete
  6. Wamp server pe nhi hai sendemail

    ReplyDelete
  7. After the changing the less secure apps, still the webpage says that email send successfully but the actual mail is not received on the destination.

    ReplyDelete
  8. Email send ho raha hai local host pe par receiver pe nhi aa raha hai sir please iska solution batado

    ReplyDelete
  9. Sir Email send nhi ho rahi error da raha hai.

    ReplyDelete
  10. Hello sir
    email send successfully but the actual mail is not received

    ReplyDelete
    Replies
    1. I am getting email not sent. Plz help me

      Delete
    2. Check 'All mails' tab in gmail. Please use desktop version gmail

      Delete
    3. ya, it may be on your spam folder!!

      Delete
  11. 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\sending_mail\mail.php on line 7
    Email sending failed...

    ReplyDelete
    Replies
    1. same here ..if you have done please tell me

      Delete
    2. After changes as per the description then restart the Xampp server

      Delete
  12. mere xampp pe php.ini file nhi hai...please reply

    ReplyDelete
  13. Hotmail login Most of us had heard the name of Hotmail. First free email service in the early years of the 2000s. I am sure many of you had an account there too. Today we will talk about Hotmail and also will discuss how we can use the new version of this email service in 2020.

    ReplyDelete
  14. Hey, for me, it is showing mail not sent. Plz help

    ReplyDelete
  15. Email is sent but I did not receive it

    ReplyDelete
  16. Dear sir,
    Mail is successfully send display in php but it is not received in gmail.

    ReplyDelete
  17. Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. m2sm12856062pjf.34 - gsmtp in C:\xamppServer\htdocs\WEBPRACTICE\form14\mail.php on line 7
    Email sending failed...
    not connected suggest some help

    ReplyDelete
  18. Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. h20sm3546230pfo.105 - gsmtp in F:\xampp\htdocs\ajax\mail.php on line 9
    Email sending failed...
    can you please help me sir...

    ReplyDelete
  19. This particular is usually apparently essential and moreover outstanding truth along with for sure fair-minded and moreover admittedly useful My business is looking to find in advance designed for this specific useful stuffs… hotmail login account

    ReplyDelete
  20. Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. hotmail email

    ReplyDelete
  21. hi,
    i am unable to send smail .i have followed your videos but unable to send email for recover password. no error but email sending is fail . can you reply me . its urgent . i have tried phpmailer too that too not working

    ReplyDelete
  22. I am getting this error:
    Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. l63sm3060395pfd.122 - gsmtp in C:\xampp\htdocs\registrationFormWithMail\index.php on line 53

    ReplyDelete

  23. E-mail is successfully send display in php but it is not received in gmail.

    ReplyDelete
  24. 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\search\index.php on line 8
    Email sending failed...

    ReplyDelete
  25. E-mail is successfully send display in php but it is not received in gmail.what should i do?

    ReplyDelete
    Replies
    1. Check youy 'all mails' tab in gmail

      Delete
    2. recommended to use gmail desktop version

      Delete
  26. Replies
    1. bro i'm getting msg of else condition that email.not sent.....
      help plz i have tried all settings.

      Delete
    2. Same problem is troubling me... Plzz help

      Delete

  27. 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\email.php on line 8
    Email sending failed...

    ReplyDelete
  28. Mera laptop 64 bit ka hai. To mujhe kesa configuration karba hoga. Email send karne ke liye? May Bangladesh se hoon. Isliye mera hindi thura kam jor hai.

    ReplyDelete
  29. I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here. can i send a fax from my yahoo email

    ReplyDelete
  30. hello I am getting error:
    20-08-04 15:29:52 : Socket Error # 11001Host not found.

    Please help me with this!...

    ReplyDelete
  31. sir mera mai tu sending failed likh kar arha hai

    ReplyDelete
  32. 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\email.php on line 8
    Email sending failed...

    ReplyDelete
  33. Sir my email sending is failed what to do

    ReplyDelete
  34. sir my email are not sending....

    ReplyDelete
  35. Thanks for the blog post buddy! Keep them coming... how to send fax from cell phone

    ReplyDelete
  36. You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this..........send fax from email
    send fax from email

    ReplyDelete
  37. Yahoo mail is an web based email service. Yahoo mail service can be accessed through different devices including computer, tablets, smart phones, and more. Users with a valid Yahoo account can sign into Yahoo com to access the features of Yahoo mail. A smile web browser can be used to sign into Yahoo.com. Users can also download Yahoo app to their mobile phone and login to their account. yahoo mail sign in

    ReplyDelete
  38. buy smart carts online. organic smart cart. are the high potency distillate free from any solvents. If this product was accurate with its claim.

    ReplyDelete
  39. Enrich your experience of online shopping by navigating our Skin Care products including Hair removal products, Facial cleansing brush, Epilators and much ...

    IPL HAIR REMOVER,
    FACIAL BRURSH,
    HAIR TRIMMER,
    MICRODEBRASION,
    BLACKHEAD REMOVER,
    WATERPROOF PORTABLE,

    ReplyDelete
  40. Email sending failed...
    ab kya kare ?
    sab setting sahi ki hai .
    bar bar check bhi kiya

    ReplyDelete
  41. ערות ליווי בחיפה ברמה גבוהה ביותר בישראל. נערות ליווי בצפון לביתך או מלון תוך 30 דקות אצלך. 24/7 מגוון בנות לעיסוי פרטי ברמה הגבוהה. נערות ליווי בחיפה

    ReplyDelete
  42. Royal photo Booths Australia At Royal Booths,we want to make a good impression with you, hence we go above & beyond when it comes to forming that initial relationship with our customers.

    ReplyDelete
  43. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. send receive fax from cell phone android

    ReplyDelete
  44. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. how to send fax from smart phone

    ReplyDelete
  45. Our store offers many styles of advanced tpe sex dolls, soft skin made of tpe material, realistic tpe sex dolls to achieve your desire for sex.Buy real realistic tpe ... realistic sex doll

    ReplyDelete
  46. I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here. receive and send a fax online

    ReplyDelete

  47. Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. u14sm13179064pfm.80 - gsmtp in C:\xampp\htdocs\email\index.php on line 7
    Email sending failed...

    error coming

    ReplyDelete
  48. Email sending failed...
    ab kya kare ?
    sab setting sahi ki hai .
    bar bar check bhi kiya
    Happy new year 2021

    ReplyDelete
  49. What does it cost to live in the Bay area? When it comes to the most desirable cities in the United States? The first city that comes to our head is the Bay Area, the panorama is breath-taking and beautiful, the weather is astonishing and the diversity is phenomenal.

    ReplyDelete
  50. 7 Coolest Offices in California

    When you first heard the word office? What is the first thing that comes into your mind?

    You must be wondering that offices only mean white walls, dark doors, and white cubicles.

    These were the days of the Grey that now has been gone.

    Nowadays, many companies invest their money in the interior of the offices because it’s truly said, “You should love the space where you work”.

    ReplyDelete
  51. 5 effective ways in which you can promote your business

    Every other business owner wants to showcase that their business is the best and they can deliver the best products and services and all they want is to put their services in front of the potential customers. However, there are many traditional ways in which one can promote business but all these traditional ways of promoting can indeed be strenuous and costly......

    ReplyDelete
  52. Key benefits of hiring a moving company in California

    The process of moving is indeed strenuous and moving across city lines is much more chaotic. Therefore, moving across California and other ...

    ReplyDelete
  53. Motivating your team in hard times


    Our store offers many styles of advanced tpe sex dolls, soft skin made of tpe material, realistic tpe sex dolls to achieve your desire for sex.Buy real realistic tpe ...

    ReplyDelete

  54. Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. u4sm3991241pga.36 - gsmtp in D:\xsmpp\htdocs\work\legalized\mailer\mailing.php on line 36
    Email sending failed...


    ReplyDelete
  55. Email sending failed...
    echo ho raha hai only, kya kre??

    ReplyDelete