【发布时间】:2014-02-10 18:22:05
【问题描述】:
我正在尝试使用 Swiftmailer 发送电子邮件,但收到以下错误:
致命错误:在第 20 行对 x 中的非对象调用成员函数 send()
这是我的代码:
<?php
require_once('swift/lib/swift_required.php');
$to = $_POST['email'];
if(empty($to)) {
header("Location: index.php?error=empty");
}
echo $to;
$body="This is my message!";
$message = Swift_Message::newInstance('Some subject')
->setFrom(array('example@example.com' => 'John Doe'))
->setTo($to)
->setBody($body);
$message->attach(Swift_Attachment::fromPath("myfile.pdf"));
$result = $mailer->send($message); // line 20
?>
谁能帮帮我?
【问题讨论】:
-
$mailer在你的代码中应该来自哪里……?
标签: php email object swiftmailer