为什么我在 Swiftmailer 中收到此错误:意外的 T_OBJECT_OPERATOR
我第一次尝试使用 swiftmailer。当我使用下面的代码时,我遇到了许多错误,其中包括这一错误:“意外的 T_OBJECT_OPERATOR”。 对我在这里可能做错了什么有什么想法吗?
require_once('/home/name/php/lib/swift_required.php');
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/exim -bs');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
->setSubject('Inquiry');
->setFrom(array('[email protected]' => 'Inquiry'))
->setTo(array('[email protected]' => 'John Doe'))
->setBody('Test inquiry message');
$numSent = $mailer->send($message);
printf("Sent %d messages\n", $numSent);
$result = $mailer->send($message);
I am trying to use swiftmailer for the first time. I am getting a number of errors when I use the code below, including this one: "unexpected T_OBJECT_OPERATOR."
Any thoughts on what I might be doing wrong here?
require_once('/home/name/php/lib/swift_required.php');
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/exim -bs');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
->setSubject('Inquiry');
->setFrom(array('[email protected]' => 'Inquiry'))
->setTo(array('[email protected]' => 'John Doe'))
->setBody('Test inquiry message');
$numSent = $mailer->send($message);
printf("Sent %d messages\n", $numSent);
$result = $mailer->send($message);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的分号太多了……:
You have one semicolon too many...:
在
Swift_Message::newInstance()
之后,您有;
导致 PHP 中出现解析错误You had
;
afterSwift_Message::newInstance()
causing parse error in PHP