1

当我发送带有 html 标签的电子邮件时。Gmail 也会显示标签。这是为什么?任何解决方案?如何根据我的代码为图片加粗文字彩色文字?这是我的电子邮件内容代码

 smtpmailer("$email", 'website@yahoo.com', '<html><body>website.lk Password recovery', 'Password recovery','Dear "'.$name."\"\n\nUse your new password to login and reset your password as you wish.\nTo reset password go to your \"My Account\" page and click \"Change my password\"\n\n"."Here is your new password:\n\n"."Password: "."$password"."\n\nBack to get bump: www.website.lk\n\nRegards,\n website.lk Admin\n</body></html>");

$reset_msg="Recovery completed. Check your e-mail !";       
}else{
$reset_msg="Error in sending email.Try again !";

}
4

3 回答 3

2

通过包括以下标题

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";


    $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
    $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
    $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
    $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";


    mail($to, $subject, $message, $headers);

来源,

http://php.net/manual/en/function.mail.php

如果您使用的是 PHP Mailer,

$mail->MsgHTML($body);

$mail->AddAttachment("images/image1.gif");      
$mail->AddAttachment("images/image2.gif"); 
于 2012-09-15T07:53:35.883 回答
0

如果您正在使用此功能:

function smtpmailer($to, $from, $from_name, $subject, $body) { 
    global $error;
    $mail = new PHPMailer();  // create a new object
    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 0;  // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true;  // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465; 
    $mail->Username = GUSER;  
    $mail->Password = GPWD;           
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AddAddress($to);
    if(!$mail->Send()) {
        $error = 'Mail error: '.$mail->ErrorInfo; 
        return false;
    } else {
        $error = 'Message sent!';
        return true;
    }
}

然后将$mail->Body = $body;代码行更改为:

$mail->MsgHTML($body);

此更改将允许您通过 PHPMailer 发送 HTML 电子邮件,您还可以添加$mail->CharSet = 'UTF-8';以避免将来出现特殊字符问题...

于 2012-09-15T08:00:25.590 回答
0

使用 $mail->IsHTML(ture); 如果在phpmailer ..

于 2014-08-14T05:19:44.707 回答