send an email script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
freelancelote
Forum Newbie
Posts: 4
Joined: Mon Mar 02, 2009 2:56 am

send an email script

Post 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?
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

Re: send an email script

Post by agriz »

Code: Select all

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

Thanks
freelancelote
Forum Newbie
Posts: 4
Joined: Mon Mar 02, 2009 2:56 am

Re: send an email script

Post by freelancelote »

Hi,
thanks agriz for the answer but I had no luck.
nmreddy
Forum Commoner
Posts: 25
Joined: Wed Feb 18, 2009 5:36 am

Re: send an email script

Post by nmreddy »

try with these headers

$headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
$headers .= "MIME-Version: 1.0 ";
freelancelote
Forum Newbie
Posts: 4
Joined: Mon Mar 02, 2009 2:56 am

Re: send an email script

Post by freelancelote »

Hi,
thanks nrreddy. This doesn't work either. I just get the echo mail sent but no mail on my inbox.
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

Re: send an email script

Post 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"
freelancelote
Forum Newbie
Posts: 4
Joined: Mon Mar 02, 2009 2:56 am

Re: send an email script

Post 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.
Post Reply