Beginning PHP

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
count_spacula
Forum Newbie
Posts: 3
Joined: Thu Aug 13, 2009 5:18 am

Beginning PHP

Post 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
robnet
Forum Commoner
Posts: 85
Joined: Mon Aug 10, 2009 8:32 am
Location: South East, UK

Re: Beginning PHP

Post 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
count_spacula
Forum Newbie
Posts: 3
Joined: Thu Aug 13, 2009 5:18 am

Re: Beginning PHP

Post 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
mars_rahul
Forum Newbie
Posts: 12
Joined: Thu Aug 06, 2009 12:22 am

Re: Beginning PHP

Post 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,
count_spacula
Forum Newbie
Posts: 3
Joined: Thu Aug 13, 2009 5:18 am

Re: Beginning PHP

Post 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
mars_rahul
Forum Newbie
Posts: 12
Joined: Thu Aug 06, 2009 12:22 am

Re: Beginning PHP

Post by mars_rahul »

Please check configuration of web server for email -> php.ini files
That will be the other reason
Post Reply