我们有简单的php类,通过php mail发送消息
$message = file_get_contents($this->message_file);
$this->message = base64_encode($message);
foreach($this->to as $to){
$code .= '
$to = "'.$to.'";
$headers = "MIME-Version: 1.0" . "\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\n";
$headers .= "From: '. $this->from .' " . "\n";
$subject = "Test message from ".$_SERVER[\'SERVER_NAME\'];
mail($to, $subject, base64_decode("'.$this->message.'"), $headers);
';
它工作正常,直到我们必须发送带有CSS,图像和其他东西的正确HTML页面。 Gmail只是没有显示正确(没有图像,没有CSS)。如何以正确的方式解决此问题并格式化邮件,以便google邮件正确显示?