Hi, I have a problem that is eating me up inside.
I follow a MVC Pattern and using Zend framework (1.5.3).
My problem is that if I use Zend_Mail or Zend_Db, and the code inside my action (where I send the mail or calls some SQL-Query) runs twice or even three times. Ergo I get 2-3 mails och 2-3 inserts in the db table).
If I put 'echo "blabla";' it echos out 1 time only, for me thats normal but why does my mail/querys run twice ?

This is the bootstrap im using for this project.
Code PHP:
include("Zend/Loader.php");
class Bootstrap
{
	public static $frontController = null;
	public static $registry = null;
	public static $view = null;
	public static $viewRenderer = null;
	public static function run()
	{
		self::prepare();
		$response = self::$frontController->dispatch();
		self::sendResponse($response);
	}
 
	public static function setupEnvironment()
	{
		error_reporting(E_ALL|E_STRICT);
		ini_set('display_errors', true);
		date_default_timezone_set('Europe/Stockholm');
	}
 
	public static function prepare()
	{
		self::setupEnvironment();
 
		/**
		 * Laddar nödvändiga klasser från Zend Framework och models
		 */
		Zend_Loader::loadClass('Zend_Db');
		Zend_Loader::loadClass('Zend_Db_Table');
		Zend_Loader::loadClass('Zend_Registry');
		Zend_Loader::loadClass('Zend_Config_Ini');
		Zend_Loader::loadClass('Zend_Session_Namespace');
		Zend_Loader::loadClass('Zend_Filter_Input');
		Zend_Loader::loadClass('Zend_Mail');
 
		/**
		 * Mina egna klasser
		 */
		Zend_Loader::loadClass('Menu');
		Zend_Loader::loadClass('Product');
		Zend_Loader::loadClass('Cart');
 
		/**
		 * Registrerar och kollar så klasser/funktioner existerar
		 */
		Zend_Loader::registerAutoload();
 
		self::setupRegistry();
		self::setupConfiguration();
		self::setupFrontController();
		self::setupView();
		self::setupDatabase();
		self::setupMenu();
	}
 
	public static function setupRegistry()
	{
		self::$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
		Zend_Registry::setInstance(self::$registry);
	}
 
	public static function setupDatabase()
	{
		$config = self::$registry->configuration;
 
		$db = Zend_Db::factory(
			$config->db->adapter,
			$config->db->config->toArray()
		);
 
		$db->query("SET NAMES 'utf8'");
 
		self::$registry->database = $db;
 
		Zend_Db_Table::setDefaultAdapter($db);
	}
 
	public static function setupConfiguration()
	{
		$config = new Zend_Config_Ini(
			MAIN_DIR . 'config/config.ini',
			'general'
		);
		self::$registry->configuration = $config;
	}
 
	public static function setupFrontController()
	{
		self::$frontController = Zend_Controller_Front::getInstance();
		self::$frontController->throwExceptions(true); // Disable in production
		self::$frontController->returnResponse(true);
		self::$frontController->setControllerDirectory(
			MAIN_DIR . "application/controllers"
		);
		self::$frontController->setParam('registry', self::$registry);
	}
 
	public static function setupView()
	{
		self::$view = new Zend_View;
		self::$view->setEncoding('UTF-8');
		self::$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer(self::$view);
		Zend_Controller_Action_HelperBroker::addHelper(self::$viewRenderer);
		self::$view->baseUrl = MAIN_URL;
 
	}
 
	public static function sendResponse(Zend_Controller_Response_Http $response)
	{
		$response->setHeader('Content-Type', 'text/html; charset=UTF-8', true);
		$response->sendResponse();
	}
 
	public static function setupMenu()
	{
		Zend_Loader::loadClass('Menu');
 
		// Initierar meny-klassen
		$menu = new Menu();
		// Hämtar menyn i form av en Array
		$menuArray = $menu->getMenuArray();
		// Genererar en htmlmeny som är färdig att visas
		$generatedMenu = $menu->printMenu(
			0,
			$menuArray,
			MAIN_URL
		);
 
		self::$view->generatedMenu = $generatedMenu;
		self::$view->menuArray = $menuArray;
	}
}
I use a basecontroller that the rest of my controllers extends by (class Caipo_Controller_Action extends Zend_Controller_Action).

Sample code of the email action i tested with, this is all there is, no loops, and I get 2-3 mails from 1 browser refresh
Code PHP:
....
(class CheckoutController extends Caipo_Controller_Action)
....
public function successAction()
	{
		$mail = new Zend_Mail('utf-8');
		$mail->setBodyText('46');
		$mail->setFrom('order_1@mobillagret.com', 'Johan Rehnström (Mobillagret)');
		$mail->addTo('jonas.s.eriksson@gmail.com');
		$mail->setSubject('Mobillagret - Ny order: 1');
		$mail->send();
}
Im completely lost and all out of ideas.
I would be forever greatfull for any pointers or help.