Reg:SwiftMailer Send Error

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
esther
Forum Newbie
Posts: 7
Joined: Fri Jun 29, 2007 4:25 am

Reg:SwiftMailer Send Error

Post by esther »

I have downloaded SwiftMailer Plugin But I cannot send mails.The error is
Fatal error: Call to undefined method Swift_Connection_SMTP::send()
I dont understand the error.Please give me a solution
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

We need to see the code to help you, however I think you should take a look at the documentation, as you'll see the Swift_Connection_SMTP object is not the object you should be calling send() from :wink:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Accidentally posted to a new thread:
esther wrote:Hello Sir,
Below is the code that i gave

Code: Select all

require_once "lib/Swift.php";
require_once "lib/Swift/Message.php";
require_once "lib/Swift/Connection.php";
require_once "lib/Swift/Message/Attachment.php";
//require_once "lib/Swift/Connection/Multi.php";
//require_once "lib/Swift/Connection/SMTP.php";
require_once "lib/Swift/Connection/Sendmail.php";

$swift=& new Swift_Connection_Sendmail("localhost");
$message =& new Swift_Message("My subject", "sdfsdf");
$swift->send($message, "xxx@yahoo.com", "esther@gmail.com");
echo "Sent to $sent recipients";
But i got a error in send() function.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Have I got an error in my docs or something? Everyone seems to be making this mistake lately :?

Code: Select all

$swift =& new Swift($sendmail);
You *always* need to create an instance of Swift otherwise there's nothing controlling the connection ;) The connections are just that -- connections.
Post Reply