/    Sign up×
Community /Pin to ProfileBookmark

How To Mail From Localhost Xampp ?

Folks,

Followed this instruction to setup Xampp to send mail from localhost:
https://www.geeksforgeeks.org/how-to-configure-xampp-to-send-mail-from-localhost-using-php/

And used mail() code from tutorial:
https://www.w3schools.com/php/func_mail_mail.asp

Funny thing is, none of the links show where to feed the gmail account password to use gmail smtp.

““
$to = $domain_email;
$from = “[email protected]”;
$subject = ‘Alert’;
$message = “Hello.”;
$message = wordwrap(“$message”,”30″);
mail(“$to”,”$subject”,”$message”);
““

How to fix as getting no emails coming to my inbox sent by my Xampp mailer ?

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@developer_webauthorNov 10.2020 — Ok.

This tells where to feed my gmail username & pass for sendmail() to use localhost Xampp to send mail using gmail.com smtp.

But still, the php code in my previous post is not sending out any emails!

Frustration!

I get error:

**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:xampphtdocstestpagination.php on line 234**

Why is it trying to use port 25 when in my php.ini I set it to port:587 ?

Look:

sendmail.ini

; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLMSoftwareSendmail

[sendmail]

; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:InetpubmailrootPickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=smtp.gmail.com

; smtp port (normally 25)

smtp_port=587

; SMTPS (SSL) support
; auto = use SSL for port 465, otherwise try to use TLS
; ssl = alway use SSL
; tls = always use TLS
; none = never try to use SSL

smtp_ssl=tls

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

;default_domain=mydomain.com

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

auth_username=******@gmail.com
auth_password=******

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines. do not enable unless it is required.

pop3_server=
pop3_username=
pop3_password=

; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify
; the "From: " header of the message content

force_sender=******@gmail.com

; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify
; the "To: " header of the message content

force_recipient=

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required

hostname=localhost




I hid my credentials here above.

Shall I put or not my email address on: "force_recipient=".
Copy linkTweet thisAlerts:
@developer_webauthorNov 10.2020 — Folks,

Why I trying to use sendmail from localhost ?

Cos my test site from freehost showing this error:

Fatal error: Uncaught mysqli_sql_exception: No such file or directory in /home/vol2_6/epizy.com/epiz_37597648/htdocs/conn.php:11 Stack trace: #0 /home/vol2_6/epizy.com/epiz_37597648/htdocs/conn.php(11): mysqli_connect('localhost', 'epiz_37597648', 'password', 'epiz_37597648_t...') #1 /home/vol2_6/epizy.com/epiz_37597648/htdocs/pagination.php(3): require('/home/vol2_6/ep...') #2 {main} thrown in /home/vol2_6/epizy.com/epiz_37597648/htdocs/conn.php on line 11

I replaced my password on above error with 'password'.

Not sure why php outputting my password to the browser!!!!

This code produced the error:

$to = $domain_email;
$header = "[email protected]";
$subject = 'Potential Visitor Alert';
$message = "One of our users are searching for what you may have to sell.n He/she is searching forn $search.";
$message = wordwrap("$message","30");

if(mail("$to","$subject","$message","$header"))
{
echo 'Mail Sent';
}
else
{
echo 'Mail UnSent';
}


conn.php

<?php

$server = 'localhost';
$db_user = 'epiz_37597648';
$db_password = 'password';
$db = 'epiz_37597648_test';

mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
$conn = mysqli_connect($server,$db_user,$db_password,$db);
mysqli_set_charset($conn,'utf8mb4');

if(mysqli_connect_error())
{
echo "Mysqli Connection Error" . mysqli_connect_error();
}
elseif(mysqli_connect_errno())
{
echo "Mysqli Connection Error Number" . mysqli_connect_errno();
}

?>


Why I get error ? I get no password error as password is correct.

**DB details:

Current Databases

MySQL DB Name MySQL User Name MySQL Password MySQL Host Name PHPMyAdmin

epiz_37597648_test epiz_37597648 (Your vPanel Password) sql101.epizy.com**
Copy linkTweet thisAlerts:
@developer_webauthorNov 10.2020 — I did setup php.ini following this:

https://shellcreeper.com/enable-send-email-in-xampp/

No luck. Xampp localhost not sending out emails using my gmail acount.
Copy linkTweet thisAlerts:
@NogDogNov 11.2020 — > @developer_web#1624982 Why is it trying to use port 25 when in my php.ini I set it to port:587 ?

Did you restart the web server after you made any changes?

If so, did you edit the right php.ini file? Create a PHP page with just the following and look for the section where it tells you what ini file(s) it is using.
<i>
</i>&lt;?php
phpinfo();


Of course, I've always used [PHPMailer](https://github.com/PHPMailer/PHPMailer) whenever I needed to do any mailing from PHP, but it's object-oriented, so you probably would refuse to use it.
Copy linkTweet thisAlerts:
@developer_webauthorNov 11.2020 — @NogDog#1624991

I used your method to find the php.ini and opened it and checked the mail section. It got my gmail acc details to use it. So, that file did get updated lastnight.

Restarted Xampp many times. Even now.
Copy linkTweet thisAlerts:
@developer_webauthorNov 19.2020 — @NogDog#1624991

Anything else I should try ?
Copy linkTweet thisAlerts:
@developer_webauthorNov 19.2020 — @Sempervivum

Do you mind chiming in ?
Copy linkTweet thisAlerts:
@SempervivumNov 19.2020 — @developer_web#1625212 I do not mind but there is a lack of knowledge regarding this subject.
×

Success!

Help @developer_web spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 3.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,
)...