dqnf28092 2011-07-20 18:54
浏览 55

PHPMailer和样式表格式

I'm using PHPMailer to automatically send an order acknowledgement as an HTML formatted email. Everything is working as expected except that the formatting of the acknowledgement isn't correct. I included my style sheet with an 'AddAttachment' line which seems to have fixed the header of the acknowledgement form, but the rest of the form still isn't right. Has anyone run into this situation before and know what I need to do to fix it? My edited program code follows in case it'll help!

<?php

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->SMTPDebug = 0;
$mail->IsSMTP();  // telling the class to use SMTP
$mail->SMTPAuth = true;

$mail->Port       = 25;                  // set the SMTP port
$mail->Host     = "<<smtp server>>"; // SMTP server
$mail->Username = "<<username>>";
$mail->Password = "<<password>>";

$mail->From     = "<<email address>>";
$mail->FromName = "<<name>>";
$mail->AddAddress("<<email address>>");

$mail->Subject  = "Acknowledgement Form";
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->IsHTML(true);

$mail->Body = file_get_contents('<<acknowledgement form page>>');
$mail->AddAttachment('printer.css'); // attach style sheet

if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
  • 写回答

1条回答 默认 最新

  • dtx6087 2011-07-22 10:15
    关注

    You should'nt work with external CSS files in emails... Not many of the email-clients can handle that and not all of your customers use email-clients like Outlook or Thunderbird. Instead, you should disgn you html-code "90s style" :-P

    e.g. <p style="width: 200px; text-align: center;">

    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法