2

i want to send email using php through xampp server.here is my code

<?php
$to = 'atchibabu@solbaacken.com';
$subject = 'My Email';
$msg = "please find details";
// Make sure to escape quotes
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: My Site Name <atchibabu516@gmail.com.com>' . "\r\n";
if(mail($to, $subject, $msg, $headers))
{
echo "success";
}
else
{
echo "fail";
}
?>

when i execute i get "success" message but i didn't get any mail i am waiting still one hour i don't know why it's happening. some suggestions send email using smtp so can any one guide how could i use the smtp.i am using mac xampp so any one guide me i could i install smtp in mac xammp.

thanks for advance.

Ajay516
  • 45
  • 2
  • 10

3 Answers3

2

Few things to note:

Your from has 2 .com so, probability of your message going in SPAM is almost 90%.

Check your phpinfo(); output. What does sendmail_path show? Do you have that software installed? Ideally it is /usr/sbin/sendmail -t -i and the software is sendmail in ubuntu machines. Also, in your phpinfo(), check the SMTP port. Also there is a high possibility of getting blocked by a firewall or similar software, checked it already?

Keval Domadia
  • 4,768
  • 1
  • 37
  • 64
  • hey perfect.just now i check spam i get email.SMTP port is 25.so what to do get emails inbox.please guide me – Ajay516 Sep 05 '12 at 06:42
  • If this worked for you, click on the 'tick' next to the answer! About Inbox part then you have to make sure that you pass correct headers. Besides, the headers which I see here seem to be correct. On live server with valid resolving hostname, it should work :) – Keval Domadia Sep 05 '12 at 06:51
  • so why it's happing emails going to spam in local host is any thing wrong in header can you guide me – Ajay516 Sep 05 '12 at 07:01
  • hi @karmicdice: do you have any idea get email in inbox – Ajay516 Sep 05 '12 at 07:14
  • that is what I said? your IP address is 127.0.0.1 which resolves to hostname localhost. Then, there are IP address which will resolve to your domain name, for example ip of yahoo.com will resolve to yahoo.com... localhost is not a valid hostname when it comes to WAN... So have a hosting, have a domain, and use the script! it will not go in spam. – Keval Domadia Sep 05 '12 at 07:32
  • One simple Question: Have you started Mercury so that your mails can get processed? – pila Sep 05 '12 at 09:09
  • Ages ago! But, that is irrelevant to the current answer. Google for Dan Murphy's tutorial on Mercury XAMPP. It is easy one :) – Keval Domadia Sep 05 '12 at 09:31
1

You should configure your email on localhost
here is the step by step way to configure your smtp

  1. Open the “php.ini“. You should know where it is located because it depends upon the particular server you’re running.
  2. Search for the attribute called “SMTP” in the php.ini file.Generally you can find the line “SMTP=localhost“. change the localhost to the smtp server name of your ISP. And, there is another attribute called “smtp_port” which should be set to 25.I’ve set the following values in my php.ini file.

        SMTP = smtp.wlink.com.np  
        smtp_port = 25
    
  3. Restart the apache server so that PHP modules and attributes will be reloaded.

  4. Now try to send mail

Reff link is here

helpfull links
http://expertester.wordpress.com/2010/07/07/how-to-send-email-from-xampp-php/

chhameed
  • 4,406
  • 4
  • 26
  • 44
0

Edit your SMTP. If you want to test it in your localhost, try installing Mozilla Thunderbird for localhost email and create new account using Mercury from Xampp.

anon
  • 855
  • 12
  • 22