Page 1 of 1

Beginning PHP

Posted: Thu Aug 13, 2009 5:19 am
by count_spacula
Hi all,

Could someone please help me out? I have quite a bit of programming experience in a number of languages, but am new to PHP, and can't figure out why this VERY SIMPLE php email script won't work!!! So frustrating, it just returns a blank screen, which I assume means a syntax error?

Code:



<?php
$to = "me@me.com";
$subject = "dummy subject";
$body = "dummy body";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>

Thanks to anyone who can help me out!!

t

Re: Beginning PHP

Posted: Thu Aug 13, 2009 7:02 am
by robnet
I can't see anything obviously wrong with the code, though I haven't parsed it.

Have you got error reporting on? viewtopic.php?f=1&t=21400

Re: Beginning PHP

Posted: Thu Aug 13, 2009 7:47 am
by count_spacula
Hey, thanks for your help.

Downloaded the PHP environment, and it should work fine. I have posted the above PHP script to my website on my contact form, just to check the script, but I dont receive the email the script dictates. Is there soe special process I have to go through to make it work. The web server is definitely PHP enabled.

Thanks,

Tom

Re: Beginning PHP

Posted: Thu Aug 13, 2009 7:57 am
by mars_rahul
Instead of the line below better use email address of Hotmail, Gmail, or yahoo. Also check junk messages also.

$to = "me@me.com";

This email address may be wrong and all the script you have written is correct.


Thanks,

Re: Beginning PHP

Posted: Thu Aug 13, 2009 4:22 pm
by count_spacula
Thanks for your help.

The PHP should work, but I never end up receiving the email when I click the submit button on the form. The PHP is definitely being triggered, but i don't get why it doesnt send me the mail!!! ARGGGHH!!!

Please helpme, you will be a life saver,

T

Re: Beginning PHP

Posted: Thu Aug 13, 2009 8:54 pm
by mars_rahul
Please check configuration of web server for email -> php.ini files
That will be the other reason