Php 需要使用带有Kohana包装的Swift mailer的帮助吗
我现在的代码是Php 需要使用带有Kohana包装的Swift mailer的帮助吗,php,email,kohana,kohana-3,swiftmailer,Php,Email,Kohana,Kohana 3,Swiftmailer,我现在的代码是 $swift = email::connect(); $swift->setSubject('hello') ->setFrom(array('alex@example.com.au' => 'Alex')) ->setTo(array('alex@example.com.au' => 'Alex')) ->setBody('hello')
$swift = email::connect();
$swift->setSubject('hello')
->setFrom(array('alex@example.com.au' => 'Alex'))
->setTo(array('alex@example.com.au' => 'Alex'))
->setBody('hello')
->attach(Swift_Attachment::fromPath(DOCROOT . 'assets/attachments/instructions.pdf'));
$swift->send();
电子邮件::connect()
根据这一点,它似乎应该起作用
然而,我得到了一个错误
Fatal error: Call to undefined method Swift_Mailer::setSubject() in /home/user/public_html/application/classes/controller/properties.php on line 45
我已经看到,email::connect()
与文档中的示例代码完全相同。就是
- 包括正确的文件
- 返回库的一个实例
谢谢您使用的是
Swift\u邮件
实例,而不是链接到的示例中的Swift\u邮件
我想你想要这样的东西:
$swift = email::connect();
$message = Swift_Message::newInstance();
$message->setSubject('hello')
->setFrom(array('alex@example.com.au' => 'Alex'))
->setTo(array('alex@example.com.au' => 'Alex'))
->setBody('hello')
->attach(Swift_Attachment::fromPath(DOCROOT . 'assets/attachments/instructions.pdf'));
$swift->send($message);
被周五下午晚些时候诅咒。谢谢你,朋友,周末愉快!顺便说一句,我看到你来自布里斯班,如果你住在北边100公里,我会给你买瓶啤酒:P@alex:谢谢,我实际上不喝酒(我喝的最难的可能是姜汁啤酒)。祝你周末愉快!