PHP Mailer not working correctly

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
ctate76
Forum Newbie
Posts: 4
Joined: Mon Oct 13, 2008 6:03 pm

PHP Mailer not working correctly

Post by ctate76 »

Hi guys, I'm new to this forum so bear with me since this is my first post.

I have a PHP mailer form in my CSS page that will not send mail for some reason. Can anyone take a look at my code and maybe help out? Thanks in advance for any help.

I've got my php file saved in the same directory as my html if that helps.

HTML:

Code: Select all

<form method="post" action="mailer.php"></form>
        <label for="name">name:</label>
        <input type="text" name="name" size="30"></input><br />
        <br />
        <label for="address">email:</label>
        <input type="text" name="email" size="30"></input><br />
        <br />
        <label for="message">message:</label>
        <textarea rows="9" name="message" cols="60"></textarea>
        <br />
        <input class="submit_input" type="submit" value="Send" name="submit"></input>
PHP:

Code: Select all

<?php
if(isset($_POST['submit'])) {
$to = "christian.tate@gmail.com";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
 
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
 
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: PHP Mailer not working correctly

Post by jaoudestudios »

What server are you running?
ctate76
Forum Newbie
Posts: 4
Joined: Mon Oct 13, 2008 6:03 pm

Re: PHP Mailer not working correctly

Post by ctate76 »

This is where I show how inexperienced I am with all this. Not sure, would Linux be the answer? Apparently it also says that I have PHP 5x version. I know this isn't much but again, server-side is all so new to me. Thanks again.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: PHP Mailer not working correctly

Post by jaoudestudios »

The reason I ask is to find out if you have a mailserver on the server to send an email using the php mail function.

Do you have emails hosted on the server?
Post Reply