php
  • html
  • css
  • 2013-10-09 352 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); 
    
    相关问题