2017-03-03 127 views
0

我想做一個PHP腳本,向用戶發送確認電子郵件,包括必須單擊的鏈接,以便激活用戶帳戶。在Outlook中的電子郵件鏈接的PHP問題

已經過測試,可以正常工作,例如gmail電子郵件帳戶。

$message = "Confirm your email. 
      Click the link below to confirm your account. 
      https://testonly.000webhostapp.com/web_emailconfirm.php?user_name=$user_name&confirm_code=$confirmCode"; 

mail($email,"Confirmation email",$message,"From: [email protected]"); 

一旦在電子郵件中的鏈接被點擊,它會打開內部運行的核查另一個PHP腳本的網站,用戶數據庫被一些新的值更新。

的問題是:它似乎像,在Outlook,只需打開電子郵件似乎是觸發的鏈接,因爲PHP代碼運行和用戶的數據庫進行更新,其實之前單擊鏈接。

這是怎麼回事?

+0

鏈接是否故意不在錨標籤中? –

+0

對於我的「新手」無知感到抱歉...你在'錨標記'中意味着什麼?我拿了從另一個地方發送電子郵件的代碼,它的工作原理如此...... – codeKiller

回答

0

嘗試改變

$message = "Confirm your email. 
     Click the link below to confirm your account. 
     https://testonly.000webhostapp.com/web_emailconfirm.php?user_name=$user_name&confirm_code=$confirmCode"; 

$message = "Confirm your email. 
     Click the link below to confirm your account. 
     <a href='https://testonly.000webhostapp.com/web_emailconfirm.php?user_name=$user_name&confirm_code=$confirmCode'>https://testonly.000webhostapp.com/web_emailconfirm.php?user_name=$user_name&confirm_code=$confirmCode</a>"; 

UPDATE

你也應該沿着HTML郵件標題傳遞

$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 

您可以瞭解更多​​

+0

檢查示例3鏈接我提供 –

+0

謝謝,我會看看,並測試你的答案 – codeKiller