Page 1 of 1
Send mail at localhost
Posted: Wed Aug 29, 2012 6:27 am
by GiaTuan
I have successfully sent mail.Yesterday, I received mail from php.Today,I can not find it in the mail box and spam.I know PHPMailer.But I want to try the mail function at localhost.
my code:
Code: Select all
<?php
ini_set("SMTP","localhost");
ini_set("SMTP_PORT", 25);
ini_set("sendmail_from","admin@localhost");
$msg="hi.";
$headers = "From:admin@localhost";
$to="john12@yahoo.com";
if(mail($to,"Re info",$msg)){
echo "ok";
}
?>
I using xampp.
Re: Send mail at localhost
Posted: Wed Aug 29, 2012 2:10 pm
by califdon
The PHP mail() function depends on there being a local mail server running. "For the mail functions to be available, PHP requires an installed and working email system. The program to be used is defined by the configuration settings in the php.ini file." (from w3schools.com) XAMPP doesn't include a mail server. Have you installed a mail server on your computer?
Re: Send mail at localhost
Posted: Wed Aug 29, 2012 3:14 pm
by Live24x7
if you merely want to check if your mail functions are working properly or not,
try some server emulation tool which emulates smtp server on your localhost
I use:
http://www.toolheap.com/test-mail-server-tool/
It will not send mails but will dump copies of mail into .txt documents. You can read them like any other emails.
Re: Send mail at localhost
Posted: Wed Aug 29, 2012 3:31 pm
by califdon
Good tip, Live24x7! Thanks.
Re: Send mail at localhost
Posted: Wed Aug 29, 2012 3:46 pm
by Live24x7
glad u found it useful. so far, i have only used this forum to get free help

Re: Send mail at localhost
Posted: Thu Aug 30, 2012 6:22 am
by GiaTuan
Sometimes I get many of the same mail

.What happened?Can anyone explain?Have xampp limited time to send a mail?
Re: Send mail at localhost
Posted: Thu Aug 30, 2012 11:41 am
by califdon
GiaTuan wrote:Sometimes I get many of the same mail

.What happened?Can anyone explain?Have xampp limited time to send a mail?
No, I would suggest that you check your script.