php mail fonksiyonu

3 Cevap php
<?php
$sendto = "account@gmail.com";
$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.

Ben herhangi bir ek yapılandırmaları gerekiyor?

önceden thx!

3 Cevap

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

Bir SMTP sunucusu yoksa, PHP örneklerde gibi tüm başlıkları geçmek için deneyin:

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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

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

Eğer çalışan bir SMTP sunucusu kullanmak üzere ayarlanmış PHP kurulum olduğundan emin olmak gerekir. Eğer answers to this question içinde aradığınızı bulabilirsiniz. Büyük olasılıkla canlı web sunucusu üzerinde komut test etmek gerekir ki başarısız.

Eğer localhost ile çalışıyorsanız, ben asla işe umuyoruz. Bu bir posta yapılandırılmış sunucu üzerinde sadece çalışacaktır. Bunun üzerine deneyin.