php
  • html
  • css
  • 2013-10-09 637 views 1 likes 
    1

    在這裏我有一個問題,當我發送一封郵件。它是正確的,但當我嘗試設計與HTML標籤的郵件正文它發送相同的HTML標籤到我的電子郵件收件箱。如何克服這個請告訴我。通過PHP發送郵件

    下面的PHP代碼:

    $to = "$email"; 
    $subject = "Test mail"; 
    $message = '<!Doctype html><html><head><title>Confirm Link</title></head><body><div style="color:blue">Thank u for registering with us </div> 
    <div> Hi'.$name.' Please click the below link to activate your accont</div><div><a href="http://www.websitename.com/test2/activation.php?id='.$uid.'&name='.$name.'&mail='.$email.'">Active your account now</a></div> </body></html>'; 
    
    $from = "[email protected]"; 
    $headers = "From:" . $from; 
    

    這裏我deliverd的電子郵件收件箱的消息: 這裏設計工作不顯示它同我的程序code.Please幫助我。

    確認LinkThank u代表我們註冊 HiSrinivas請點擊以下鏈接激活您的accont Active your account now

    回答

    4
    // To send HTML mail, the Content-type header must be set 
    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    

    注:

    如果打算髮送HTML或其他複雜的郵件,它是建議使用PEAR包裝»PEAR :: Mail_Mime。

    Reference

    0

    發送HTML電子郵件:

    <?php 
    $to = "[email protected], [email protected]"; 
    $subject = "HTML email"; 
    
    $message = " 
    <html> 
    <head> 
    <title>HTML email</title> 
    </head> 
    <body> 
    <p>This email contains HTML Tags!</p> 
    <table> 
    <tr> 
    <th>Firstname</th> 
    <th>Lastname</th> 
    </tr> 
    <tr> 
    <td>John</td> 
    <td>Doe</td> 
    </tr> 
    </table> 
    </body> 
    </html> 
    "; 
    
    // Always set content-type when sending HTML email 
    $headers = "MIME-Version: 1.0" . "\r\n"; 
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; 
    
    // More headers 
    $headers .= 'From: <[email protected]>' . "\r\n"; 
    $headers .= 'Cc: [email protected]' . "\r\n"; 
    
    mail($to,$subject,$message,$headers); 
    ?> 
    
    0

    的問題可能是你沒有設置郵件頭。試試這個:

    // To send HTML mail, the Content-type header must be set 
    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    
    mail($to, $subject, $message, $headers); 
    
    相關問題