> I put this PHP script on web server: > > <?php > if (mail("[EMAIL PROTECTED]", "brati", "peda", "From: Peda")== TRUE) > print("U redu je"); > else > print("Greska"); > ?> > > But It seems that mail function doesn't work. I don't get any e-mail. > > Can anyone tell me what is wrong.
Does mail() return true? I mean, do you get printed "U redu je"? If so, your email should've been sent by PHP.
You are really missing a bunch of headers. I'm not sure if this is your problem, but I think it's not a bad idea to include more headers, also because more and more ISP's add some kind of spamfilter which might drop your email. So maybe by adding more headers, you can solve this.
I use this:
$headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n"; $headers .= "X-Priority: 3\r\n"; $headers .= "X-MSMail-Priority: Normal\r\n"; $headers .= "X-Mailer: PHP/".phpversion()."\r\n"; $headers .= "From: Name <[EMAIL PROTECTED]>\r\n";
$body = "Whatever is in your email";
$to = "Name <[EMAIL PROTECTED]>"; $check_mail = mail($to, "Subject", $body, $headers);
When PHP sends an email to a non existing email address such as [EMAIL PROTECTED], the warning mail you normally get returned often does not arrive in your mailbox. Therefore I add two additional headers:
."Reply-To: [EMAIL PROTECTED]" ."Return-path: <[EMAIL PROTECTED]"
and now I do get the notification mail when mail bounces.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php