Sunday, September 30, 2018

html - Send mail by php mail() function

I have problem with sending mail message by php mail() function. I'm not sure if it's problem with code coz I have read that some hosting servers are not allowing to sends mail but I'm trying to send this mail also when website is on localhost and it still doesn't work - after click "Send" I see the information: "Your mail is sent", but when I'm checking on my postbox there is no mails (also in spam).



For me code looks good but maybe I'm missing something. The second option which I'm considering is that also my localhost is not allowing to send mails.

























srand((double)microtime()*1000000);

$marker = md5(uniqid(rand()));

$receiver = "address@gmail.com";
$title = "Mail";
$sender = $_POST['name'];
$sender .= $_POST['surname'];
$sender_mail = $_POST['mail'];

$message = $_POST['message'];


$headers = "From: $sender <$sender_mail>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed;\n";
$headers .= "\tboundary=\"___$marker==\"";

$content ="--___$marker==\n";
$content .="Content-Type: text/plain; charset=\"iso-8859-2\"\n";
$content .="Content-Transfer-Encoding: 8bit\n";
$content .="\n$message\n";


if (mail($receiver,$title,$content,$headers))
{
print "Your message is sent.";
} else {
print "Your message is not sent.

Please go back and send again.";
}
?>



Pictures with my php conf:



PHP config
PHP config
PHP config

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...