tags:

views:

31

answers:

3
<?php
$sendto = "[email protected]";
$subject = "email confirmation"; // Subject 
$message = "the body of the email - this email is to confirm etc...";
# send the email 
mail($sendto, $subject, $message);
?>

this is the code that i wrote to test mail function on localhost. i have ran the script in browser for several times and still dun receive any email in my mail box.

Do I need any additional configurations?

thx in advance!

A: 

You need to make sure that you have your PHP installation set up to use a working SMTP Server. You might find what you're looking for in answers to this question. Failing that you'll likely need to test your script on your live web server.

icio
A: 

Basically is hard to send a mail from localhost to any mail providers. They have big restrictions on the incoming mails, and the simply mail() won't work.

You need to use an SMTP server. and define that server in php configuration

smtp = localhost  #(here should be your smtp server)
smtp_port = 25

if you don't have an SMTP server, try to pass all headers like in PHP examples:

$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

http://www.php.net/manual/en/function.mail.php

Mihai Iorga
A: 

If you are working with localhost then, i hope it will never work. It will work only on a mail configured server. Please try on it.

Fero