【发布时间】:2012-01-24 15:40:14
【问题描述】:
我尝试通过 swiftmailer 发送邮件,我的代码是:
$message->setFrom($from);
$message->setBody($template, 'text/html');
$message->setTo($from);
$message->addPart($text, 'text/plain');
//$message->attach(Swift_Attachment::fromPath('D:/file.txt'));
// send message
if ($recipients = $swift->send($message, $failures)) {
但问题是我收到一条空消息! $template 是一个包含 html 代码的变量!
【问题讨论】:
-
您是否尝试打印出
$template以确保它不为空? -
耶!我在 setbody() 函数之前打印了它!没关系!
标签: php swiftmailer