Page 1 of 1

Anti-Flood-Plugin

Posted: Mon Apr 02, 2007 11:49 am
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

Posted: Mon Apr 02, 2007 2:36 pm
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