Page 1 of 1

Fatal error: Call to undefined method: swift->setusername()

Posted: Tue Jan 15, 2008 3:48 pm
by anduser
can anybody direct me to what is wrong here, I'm on PHP4
I thought I used all of the php4 code. here is what I have.

Code: Select all

include "../swiftmail/lib/Swift.php";
include "../swiftmail/lib/Swift/Connection/SMTP.php"; 
 
$smtp =& new Swift(new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS));
 
$smtp->setUsername("username@gmail.com);
$smtp->setPassword("password");
 
 
$swift = new Swift($smtp);
 
$message->headers->set("Reply-to:",$from->email_address );
$message =& new Swift_Message($subject);
$message->attach(new Swift_Message_Part($message));
    
    
    
if ($swift->send($message, $ad->email_address, $from->email_address))
    {do stuff}
 
The version of Swiftmailer is 3.3.2 PHP4

Re: Fatal error: Call to undefined method: swift->setusername()

Posted: Tue Jan 15, 2008 4:29 pm
by John Cartwright
Line 4

Code: Select all

$smtp =& new Swift(new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS));
should be

Code: Select all

$smtp =& new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);

Re: Fatal error: Call to undefined method: swift->setusername()

Posted: Tue Jan 15, 2008 5:03 pm
by anduser
Thanks for quick reply. Now I get:

Fatal error: Call to a member function on a non-object

and it's pointing to the same line number as before

Re: Fatal error: Call to undefined method: swift->setusername()

Posted: Tue Jan 15, 2008 6:29 pm
by anduser
Thanks, I got it figured out, I was passing a wrong parameter into it.