我的代码不起作用(php)

时间:2016-07-28 08:56:34

标签: php email alert

我的代码在数据库中保存信息,但不会将消息发送到电子邮件,并且警报消息不起作用。 你能帮我吗 ?

`

if(isset($_POST['send'])){
    $to = "nada_26_@hotmail.com"; // this is your Email address
    $subject = "Form contact";
    $subject2 = "Copy of your form submission";
    $name = $_POST['name'];
    $from = $_POST['email'];
    $subject3 = $_POST['subject'];
    $company = $_POST['company'];
    $content = $_POST['message'];
    $message = "Name: ".$name ." Subject: " . $subject3 . " Company: " . $company ."\n\n".$content;
    $message2 = "Here is a copy of your message " . "\n\n" . $_POST['message'];

    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers); //send the message to the admin
    mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender


    $sql ="INSERT INTO threadnn_arab.contactus VALUES('$name','$from','$subject3','$company','$message','')";
    $result=mysql_query($sql); 
             echo "<script> alert('Mail Sent, Thank you, we will contact you shortly.'); </script>";


                  header('Location: index.php?#contact');           
                }
?>  `

1 个答案:

答案 0 :(得分:0)

我认为在您的电子邮件提供商处,smtp可能是。或者您可以使用PHPMailer看起来像这个问题Send email from Hotmail using php