Page 1 of 1

New to PHP, help with a basic mail script

Posted: Fri Jun 12, 2009 10:26 am
by licwid
I have a basic mail script that runs without errors, but does not send me an email. Its not being spam filtered I checked, I'm just not receiving it at all.

Code: Select all

<?php
    $to         = 'my@email.address';
    $from       = $_REQUEST['Email'];
    $name       = $_REQUEST['Name'];
    $company    = $_REQUEST['Company'];
    $phone      = $_REQUEST['Phone'];   
    $subject    = $_REQUEST['Subject'];
    $message    = $_REQUEST['Message'];
    $headers    = "From: $from";
    $body       = "Name: $Name \nCompany: $company \nPhone: $phone \n$message";
 
    if(!$from || !$name || !$message) {print "You have not completed all the required fields, please go back and try again";}
    else 
    {
        $send = mail($to, $subject, $body, $headers);
        if($send) 
        { 
            echo "<script language=\"JavaScript\">\n";
            echo "alert(\"Your E-Mail was sent successfully.\");","\n";
            echo "window.location = 'ReDirect URL'";        
            echo "</script>"; 
        }
        else 
        { 
            echo "<script language=\"JavaScript\">\n";
            echo "alert(\"We encountered an error sending your mail, please notify me.\");","\n";
            echo "window.location = 'ReDirect URL'";        
            echo "</script>";           
        }
    }
?>
Any ideas?

Thanks
-Licwid

Re: New to PHP, help with a basic mail script

Posted: Fri Jun 12, 2009 10:45 am
by akuji36