2013-03-27 59 views
0

我試圖在用戶註冊我的網站時向用戶發送包含確認碼的電子郵件。該電子郵件發送很好,但是當我把全長URL,郵件沒有發送向用戶發送確認電子郵件

在這裏你可以看到,我使用的代碼:我需要把在全

$message = 'You have recieved this email because you have signed up to Amped. To complete the registration process, please 
click on the link below. <br/> <a href=confirm.php?code=' . $row['emailcode'] . '>Click here to complete registration</a>' 

在confirm.php之前的鏈接工作,但當我這樣做,電子郵件不會發送。有任何想法嗎?

+0

你在使用什麼庫?只是'mail()'或更復雜的東西? – Uby 2013-03-27 20:43:47

+0

你是什麼意思「電子郵件不發送」。它可能是垃圾郵件過濾器問題嗎?你的域名中是否有正確的spf/domain keys條目?您是否嘗試過首先手動發送相同的電子郵件。 – 2013-03-27 20:45:47

回答

1

您正在發送相對路徑。你需要使用urlencode發送到文件的完整路徑:

$message = '<a href="' . urlencode("http://www.example.com/confirm.php?") . $row['emailcode'] . '">'; 
0

你缺少報價:

$message = 'You have recieved this email because you have signed up to Amped. To complete the registration process, please click on the link below. <br/> <a href="confirm.php?code=' . $row['emailcode'] . '">Click here to complete registration</a>' 
0

你應該確保消毒那個url變量,其編碼爲安全網址的使用,以及然後在confirm.php中對其進行解碼。直接將db值轉換爲url不是一個好主意。 urlencode()是一個不錯的解決方案。無法做到這一點couold導致網址中斷,並通過擴展,你的腳本。

$code = urlencode($row['emailcode']); 

$msg = "stuff.. <a href='http://www.example.con/confirm.php?code=". htmlentities($code) ."'>Click here</a>"; 
相關問題