Call to member function setusername() on a non object

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
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Call to member function setusername() on a non object

Post 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
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Well, it seems that $smtp isn't set. What this tells you?

Code: Select all

var_dump($smtp);
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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);
Post Reply