Page 1 of 1

send an email script

Posted: Mon Mar 02, 2009 4:22 am
by freelancelote
Hi,
I'm trying to set a send an email script on my index.php page. As it happens I tried the following script that I found doing some search:

Code: Select all

<html>
<head>
<title>PHP Mail Array Loop</title>
</head>
<body>
<?php
$to = "somename@domain.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "anyname@space.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
 
?>
</body>
</html>
I save that as index.php and put it on my server.

Instead of somename@domain.com and anyname@space.com I put real email addresses.
For some reason I'm not getting any email but just the "mail sent".

Now, since my php skills suck I'm turning to you to find some help.
Could anybody please tell me what I am doing wrong?

Re: send an email script

Posted: Mon Mar 02, 2009 4:45 am
by agriz

Code: Select all

if(mail($to,$subject,$message,$headers)){
    echo "Mail sent..";
}
 
Try this and reply with your output.

Thanks

Re: send an email script

Posted: Mon Mar 02, 2009 4:57 am
by freelancelote
Hi,
thanks agriz for the answer but I had no luck.

Re: send an email script

Posted: Mon Mar 02, 2009 5:02 am
by nmreddy
try with these headers

$headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
$headers .= "MIME-Version: 1.0 ";

Re: send an email script

Posted: Mon Mar 02, 2009 5:09 am
by freelancelote
Hi,
thanks nrreddy. This doesn't work either. I just get the echo mail sent but no mail on my inbox.

Re: send an email script

Posted: Mon Mar 02, 2009 5:10 am
by agriz
agriz wrote:

Code: Select all

if(mail($to,$subject,$message,$headers)){
    echo "Mail sent..";
}
 
Try this and reply with your output.

Thanks

Did you see the word "Mail Sent"

Re: send an email script

Posted: Mon Mar 02, 2009 5:20 am
by freelancelote
agriz wrote:
agriz wrote:

Code: Select all

if(mail($to,$subject,$message,$headers)){
    echo "Mail sent..";
}
 
Try this and reply with your output.

Thanks

Did you see the word "Mail Sent"
Yes, I did see the "mail sent" part but received no mail.