2015-08-21 79 views
-2

你可以在標題上看到。 我會在這裏發佈我的代碼。我請,如果我做了碼撥錯請PHP - 爲什麼我的電子郵件發送代碼不起作用?

<?php 
$name = $_REQUEST["name"]; 
$email = $_REQUEST["email"]; 
$mobile = $_REQUEST["mobile"]; 
//$msg = $_REQUEST["msg"]; 
$to = "[email protected]"; // <--- Change email ID here 
if (isset($email) && isset($name)) { 
$subject = "Cadastro para Pos Graduacao em Lideranca e Gestao Sustentavel"; 
$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; 
$headers .= "From: <".$email.">\r\n"."Reply-To: ".$email."\r\n" ; 
$msg  = "From: Email: $email <br/>Mobile: $mobile" ; //<br/>Message: $msg 

    $mail = mail($to, $subject, $msg, $headers); 
    if($mail) 
    { 
     echo 'success'; 
    } 

else 
    { 
     echo 'failed'; 
    } 
} 

?> 

以及..此代碼適用於其他projets ..所以我不知道我在做什麼錯..

+0

不工作? –

+0

可能smpt沒有配置? – SergeyAn

+0

同一臺服務器上的其他項目?使用相同的形式?當你加載這個錯誤消息/警告嗎? – chris85

回答

0
if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])) { 


$name = $_REQUEST["name"]; 
$email = $_REQUEST["email"]; 
$mobile = $_REQUEST["mobile"]; 


$headers = "From: information <".$email.">\n"; 
$headers .= 'MIME-Version: 1.0' . "\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n"; 
$to='[email protected]'; 
$subject = 'subjenct'; 
$message = "<html> 
    <body> 
    <p style='font-family:verdana; font-size:12px; margin:30px 0 0 30px; align=center'> 
    <strong> Information </strong> <br> 
     <strong>Full Name: </strong> ".$name."<br> 
     <strong>Email: </strong> ".$email."<br> 
     <strong>Mobile: </strong> ".$mobile."<br> 
    </p> 
    </body> 
    </html>"; 

    $res= mail($to, $subject, $message, $headers); 

} 

if($res) 
{ 
echo 'success'; 
} 
else 
{ 
    echo 'failed'; 
} 
+0

你應該寫下你改變的和爲什麼。另外,如果字段未被設置,'$ res'將會被定義爲不確定。 – chris85

+1

你可以在上面的代碼中說出問題! –

相關問題