需要使用 Kohana 包装器的 Swift 邮件程序帮助
我当前的代码是
$swift = email::connect();
$swift->setSubject('hello')
->setFrom(array('[email protected]' => 'Alex'))
->setTo(array('[email protected]' => 'Alex'))
->setBody('hello')
->attach(Swift_Attachment::fromPath(DOCROOT . 'assets/attachments/instructions.pdf'));
$swift->send();
email::connect()
返回 SwiftMailer 的实例。
根据这些文档,它似乎应该有效。
但是,我收到一个错误,
Fatal error: Call to undefined method Swift_Mailer::setSubject() in /home/user/public_html/application/classes/controller/properties.php on line 45
我发现 email::connect()
的作用与文档中的示例代码完全相同。那就是
- 包含正确的文件
- 返回库的实例
我做错了什么?
谢谢
My current code is this
$swift = email::connect();
$swift->setSubject('hello')
->setFrom(array('[email protected]' => 'Alex'))
->setTo(array('[email protected]' => 'Alex'))
->setBody('hello')
->attach(Swift_Attachment::fromPath(DOCROOT . 'assets/attachments/instructions.pdf'));
$swift->send();
The email::connect()
returns an instance of SwiftMailer.
As per these docs, it would seem that it should work.
However, I get an error
Fatal error: Call to undefined method Swift_Mailer::setSubject() in /home/user/public_html/application/classes/controller/properties.php on line 45
I've seen that email::connect()
does exactly what the example code in the docs does. That is
- include the correct file
- return an instance of the library
What am I doing wrong?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的是
Swift_Mailer
实例,而不是您链接到的示例中的Swift_Message
。我想你想要这样的东西:
You're using a
Swift_Mailer
instance, not aSwift_Message
like in the example you linked to.I think you want something like this: