PHP不能发送HTML模板到电子邮件

问题描述 投票:0回答:1

我的问题是,当你注册一个用户生成的随机代码,发送到电子邮件,我做了一个模板的电子邮件,包含基本的文本与风格,这封电子邮件只改变了基本链接与生成的代码。因此,一切都应该工作,因为我的意思,但目前在注册期间的电子邮件,但没有我给的风格。下面的代码。

$to = $email;
$subject = "Registration Confirmation";

$link = "<a href='".DIR."/activation?x=$latest_id&y=$activasion'>".DIR."/activation?x=$latest_id&y=$activasion</a>";

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

$headers .= 'From: '.$from."\r\n".
            'Reply-To: '.$from."\r\n" .
            'X-Mailer: PHP/' . phpversion();

$message = file_get_contents("inc/user_register.html");
$message = str_replace('[link]', $link, $message);

mail($to, $subject, $message, $headers);
header("location: /login?action=joined");
php mysql email html-email
1个回答
1
投票

你在第一个headers[]处缺少了\n。你也可以尝试这种方式来设置头。

// To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';

// Additional headers
$headers[] = 'To: Mary <[email protected]>, Kelly <[email protected]>';
$headers[] = 'From: Birthday Reminder <[email protected]>';
$headers[] = 'Cc: [email protected]';
$headers[] = 'Bcc: [email protected]';

// Mail it
mail($to, $subject, $message, implode("\r\n", $headers));


0
投票

问题解决

我使用从谷歌字体网站导入字体。我已经删除了它的风格和工作像我想要的。

© www.soinside.com 2019 - 2024. All rights reserved.