Re: Re: mail function

From: Date: Mon, 21 Jul 2003 09:22:30 +0000
Subject: Re: Re: mail function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-156027@lists.php.net to get a copy of this message
At 10:39 21-7-03, you wrote:
I put this PHP script on web server: <?php if (mail("ena-mona@eunet.yu", "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 <You@Domain.com>\r\n"; $body = "Whatever is in your email"; $to = "Name <Where-ever@this-needs-to-go.com>"; $check_mail = mail($to, "Subject", $body, $headers);
When PHP sends an email to a non existing email address such as You@Domain.com, the warning mail you normally get returned often does not arrive in your mailbox. Therefore I add two additional headers:
    ."Reply-To: me@domain.nl\r\n"
    ."Return-path: <me@domain.nl\r\n"
and now I do get the notification mail when mail bounces.

« previous php.general (#156027) next »