Swiftmailer调用未定义的方法setPassword()

时间:2013-04-28 22:18:14

标签: php swiftmailer

我不知道为什么Swiftmailer会给我一个错误。

致命错误调用未定义的方法setPassowrd in .. lib / classes / Swift / Transport / EsmtpTransport.php

我检查过该文件,但不包含该方法。虽然我正在遵循它的正确文档,但在下面找到 http://swiftmailer.org/docs/sending.html#the-smtp-transport

我的代码是这样的:

require_once 'lib/swift_required.php';

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername('myUserName@gmail.com')->setPassowrd('myPassword');
//$transport->setLocalDomain('[127.0.0.1]');
//The above has been tried with and with out.
$theMessage = Swift_Message::newInstance();

$to = 'toEmail@example.com';
$theMessage->setTo(array($to => 'aName');

$theMessage->setSubject = 'Contact Form';
$theMessage->setBody = $body;
$theMessage->setFrom(array($email => $name));

$theMessage->WordWrap = 50;

$mailer = Swift_Mailer::newInstance($transport);
$mailer->send($theMessage);

1 个答案:

答案 0 :(得分:1)

该方法称为setPassword(),而不是setPassowrd()。你拼错了。

Source

Documentation