1

I have no idea why Swiftmailer is giving me an error.

Fatal error Call to undefined method setPassowrd in.. lib/classes/Swift/Transport/EsmtpTransport.php

I have checked the file and it does not contain the method. Though I am following the correct documentation for it, found below.
http://swiftmailer.org/docs/sending.html#the-smtp-transport

My code is as is:

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);
4

1 回答 1

1

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

来源

文档

于 2013-04-28T22:19:56.550 回答