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

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
anduser
Forum Newbie
Posts: 3
Joined: Tue Jan 15, 2008 3:44 pm

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

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

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

Post 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);
anduser
Forum Newbie
Posts: 3
Joined: Tue Jan 15, 2008 3:44 pm

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

Post 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
anduser
Forum Newbie
Posts: 3
Joined: Tue Jan 15, 2008 3:44 pm

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

Post by anduser »

Thanks, I got it figured out, I was passing a wrong parameter into it.
Post Reply