Anti-Flood-Plugin

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
v4ll0r733n
Forum Newbie
Posts: 1
Joined: Mon Apr 02, 2007 11:35 am

Anti-Flood-Plugin

Post by v4ll0r733n »

Hi,

actually I try to setup a newsletter script with swift (never used it before) but it seems to be a little bit complicated ;)

Code: Select all

<?
require(GLOBAL_PATH .'core/libs/swift/Swift.php');
require(GLOBAL_PATH .'core/libs/swift/Swift/Connection/SMTP.php');
require(GLOBAL_PATH .'core/libs/swift/Swift/Plugin/AntiFlood.php');
$obj_swift =& new Swift(new Swift_Connection_SMTP("localhost"));

/** snip **
 * getting stuff from db
 * $arr_recipients[] -> mail@domain.com
 * $arr_newsletter[] -> newsletter contents
 */

$obj_swift->attachPlugin(new Swift_Plugin_AntiFlood(100, 30), "anti-flood");

if($arr_newsletter['art'] == 'text'):
	$obj_swift->addPart($arr_newsletter['inhalt']);
else:
	$obj_swift->addPart($arr_newsletter['inhalt'], 'text/html');
endif;

set_time_limit(0); ignore_user_abort();
echo "Close the browser window now...";
flush(); ob_flush();

$obj_swift->send($recipients, "\"". $arr_newsletter['name'] ."\" <". $arr_newsletter['email'].">", $arr_newsletter['title']);
$obj_swift->close(); 
?>
... this is what i've collected out of many many posts in the forum or the documentation ;)
... but it causes this error:

Code: Select all

Fatal error: Call to undefined method Swift::addPart()
It's very confusing when you're working the first time with Swift ... seems to be a very nice class, but very complicated :cry:
I started playing around the last hours and sending normal emails and stuff is no problem, but I was unable to solve this error myself :/

thx for suggestions and help!

Valentin
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You seem to have a mix of version 2 and version 3 code. I'm guessing you've found code examples online or something, but v3 has only been out since xmas time.

Have you read over the tutorials on the actual website? :) Namely the form2mail one (and the other "basic" ones above it).

http://www.swiftmailer.org/wikidocs/v3/ ... /form2mail

You have loaded the plugin correctly, but everything else is wrong ;)

EDIT | Here's the plugin example: http://www.swiftmailer.org/wikidocs/v3/ ... /antiflood
Post Reply