PHP mail didnt work

the mail() function

Moderators: macek, egami, gesf

rafee
New php-forum User
New php-forum User
Posts: 1
Joined: Sun Oct 07, 2012 12:32 am

PHP mail didnt work

Postby rafee » Sun Oct 07, 2012 12:38 am

I am Using below code to send simple mail, but it not working..

<?php
if(isset($_POST['submit_form']))
{

$to = 'sam@gmail.com';
$headers = "From: sample@hotmail.com \r\n";
$email_subject="test Mail";
$email_body="test MAIL";
mail($to,$email_subject,$email_body,$headers);


if (mail($to,$email_subject,$email_body,$headers)) {
echo("<p>Message successfully sent!</p>");
} else
{
echo("<p>Message delivery failed...</p>");
}
}
?>

JackRockerfeller
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Oct 08, 2012 3:11 pm

Re: PHP mail didnt work

Postby JackRockerfeller » Tue Oct 09, 2012 12:04 pm

It may be because you do not have a configured mail server. Are you tying this on your desktop?

I had the same problem on my Ubuntu desktop but the same code worked on my shared server (at hostgator).

I have never set up a mail server so I can't help you with that .

bitsys
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Oct 20, 2012 4:41 am

Re: PHP mail didnt work

Postby bitsys » Sun Oct 21, 2012 11:44 pm

Hello rafee
It won't work on the localhost. so you need to upload it on the web server and then try to send the email again.


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest