Code snippets for symfony 1.x

Navigation

Refine Tags

Snippets tagged "mail"

Unit Test to check the configuration of sending emails in symfony 1.4 (c / SwiftMailer)

<?php
/**
 * test/unit/maillerTest.php
 *
 * @author     Gilmar Pupo <g@g1mr.com>
 * 
 *  Unit Test to check the configuration of sending emails in symfony 1.4 (c / SwiftMailer)
 */
 
require_once dirname(__FILE__).'/../bootstrap/unit.php';
$t = new lime_test(1);
require_once sfConfig::get('sf_symfony_lib_dir').'/vendor/swiftmailer/classes/Swift.php';
Swift::registerAutoload();
sfMailer::initialize();
$dispatcher = new sfEventDispatcher();
$factories = sfYaml::load(sfConfig::get('sf_root_dir') . '/apps/backend/config/factories.yml');
$mailer = new sfMailer($dispatcher, $factories['all']['mailer']['param']);
$message = Swift_Message::newInstance('Subject test')
  ->setFrom(sfConfig::get('app_contact_emailfrom', 'from@noreply.com'))
  ->setTo(array('g@g1mr.com' => 'Gilmar Pupo'))
  ->setBody('Email content');
$numSent = $mailer->send($message);
$t->ok( $numSent > 0 );
 
by Gilmar Pupo on 2010-09-08, tagged mail  test