Page 1 of 1

Call to member function setusername() on a non object

Posted: Thu May 03, 2007 8:43 am
by pinehead18
Well through the list of noob problems i'm almost done.

Now i'm hitting this error

Fatal error: Call to a member function setUsername() on a non-object in /home/pinehead/www/dennis/new/send_newsletter.php on line 16

Code: Select all

$swift =& new Swift(new Swift_Connection_SMTP("mail.pinehead.com", 25));
$smtp->setUsername("user@pinehead.com);
$smtp->setPassword("password");
$message =& new Swift_Message("Some subject", "Your message <u>here</u>", "text/html");
 
if ($swift->send($message, "recipient@domain.tld", "you@home.tld"))
{
    echo "Message sent";
}
else
{
    echo "Message failed to send";
}
 
//It's polite to do this when you're finished
$swift->disconnect();

That is my code not including the requires.
Thanks for the help guys

Posted: Thu May 03, 2007 8:50 am
by Oren
Well, it seems that $smtp isn't set. What this tells you?

Code: Select all

var_dump($smtp);

Posted: Thu May 03, 2007 8:54 am
by Chris Corbyn

Code: Select all

$smtp =& new Swift_Connection_SMTP("mail.pinehead.com", 25);
$smtp->setUsername("user@pinehead.com"); 
$smtp->setPassword("password");

$swift =& new Swift($smtp);