2013-09-01 23 views
1

我想通過使用函數mail()發送一封郵件,在郵件中我想包含一個鏈接,問題是在我的outlock它顯示的鏈接,但不會在Chrome中打開它(當我將鼠標懸停在鏈接上時,它會給我/阻止:\在鏈接本身之前,並且在Gmail中它甚至不顯示鏈接,只顯示鏈接文本爲純文本。 ?一個標籤不發送郵件後用php

$link = 'stackoverflow.com'; 
$emailTo = '[email protected]'; 
$body = '<body><a href=\"'.$link.'\">click me</a> <br/></body>'; 
$headers = "MIME-Version: 1.0 \n" ; 
$headers .= "From: [email protected]"; 
$headers .= "Content-Type: text/html;charset=utf-8 \n"; 
mail($emailTo, 'title', $body, $headers); 

我會appritiate任何幫助

編輯:我不知道這是否意味着什麼,但是當我按我的鏈接outlock openes一個定位鏈接瀏覽器

+5

缺少的 「http://」 吧? – str

+0

@str unfortunatly它不是問題:( –

+0

請嘗試點擊「顯示原始」在Gmail和張貼在這裏。 – str

回答

1

很多時候,在我與身體內部鏈接的經驗,在From:必須是最後一個頭項並增加<!DOCTYPE html>

另外,你還需要一個http://電話。

試試這個:

<?php 

$link = "http://www.stackoverflow.com"; 
$emailTo = '[email protected]'; 
$title = "The title message"; 
$body = '<!DOCTYPE html><html><head></head><body><a href="'.$link.'">click me</a> <br/></body></html>'; 
$headers = "MIME-Version: 1.0 \n" ; 
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; 
$headers .= "From: [email protected]"; 

mail($emailTo, $title, $body, $headers); 
?>