开发者

simple php mail not sending email

Can anyone see if there is something wrong with this? I get no errors but never get the email.

    <?php
if(isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "munged@example.com";
    $email_subject = "Email sent through crankapps website";

    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }

    // validation expected data exists
    if(!isset($_POST['name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['message'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }

    $name = $_POST['n开发者_Go百科ame']; // required
    $email = $_POST['email']; // required
    $message = $_POST['message']; // required

    $error_message = "";
    $email_message = "Form details below.\n\n";

    $email_message .= "Name: ".clean_string($name)."\n";
    $email_message .= "Email: ".clean_string($email)."\n";
    $email_message .= "Message: ".clean_string($message)."\n";


// create email headers
$headers = "From: ". $name . " <" . $email . ">\n.";
mail($email_to, $email_subject, $email_message, $headers); 
?>


first, test with only one line:

<?php
    mail('munged@example.com', 'test email', 'this is a test');
?>

chances are that this will not work.

find out your smtp settings and see if smtp settings in your php.ini match them.

take look at phpmailer which lets you use more smtp settings like ssl etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜