0

I use symfony 1.4.11 , And I need to make mailing from task. I use this article. So I have next simple code for example:

class mailerSendTask extends sfBaseTask
{

  protected function configure()
  {

    $this->addOptions(array(
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name','frontend'),
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'),
      // add your own options here

    ));

    $this->namespace        = 'mailer';
    $this->name             = 'send';
    $this->briefDescription = 'Ads mailling';
    $this->detailedDescription = <<<EOF
The [mailer:send|INFO] 
    Mailing links to new ads for all users who are subscribed.

Call it with:
  [php symfony mailer:send|INFO]
EOF;


  }

  protected function execute($arguments = array(), $options = array())
  {

    // initialize the database connection
    $databaseManager = new sfDatabaseManager($this->configuration);
    $connection = $databaseManager->getDatabase($options['connection'])->getConnection();

    $context = sfContext::createInstance($this->configuration);
    $this->configuration->loadHelpers('Partial');

    $message = $this->getMailer()->compose('no-reply@some.com', 'mymailgmail.com', 'New Ads');

               // generate HTML part
            $context->getRequest()->setRequestFormat('html');
            $html  ='some text';// get_partial('ads/mailing',array ('user_id'=>$user_id));
            $message->setBody($html, 'text/html');

             // send the message

            $this->getMailer()->sendNextImmediately()->send($message);     
}

}

So task work without error, I have :

>> sfPatternRouting Connect sfRoute "sf_guard_signin" (/login)
>> sfPatternRouting Connect sfRoute "sf_guard_signout" (/logout)
>> sfPatternRouting Connect sfRoute "sf_guard_password" (/request_password)
>> sfPatternRouting Match route "homepage" (/) for / with parameters array (  'module' => 'main',  'action' => 'index',)

but the letters do not com to my email...Maybe I have incorrect code?

denys281
  • 2,004
  • 2
  • 19
  • 38

1 Answers1

3

Check out this article: http://www.symfony-project.org/more-with-symfony/1_4/en/04-Emails#chapter_04_configuration

Maybe you have set delivery_strategy to none in your dev or test environment.

scube
  • 1,931
  • 15
  • 21
  • He's running it in dev by default, the default strategy there is none. He should be running it in the prod environment. – Maerlyn Aug 10 '11 at 15:44
  • I am stupid. Yes, I have in **delivery_strategy** in dev none strategy. And my task running in dev. – denys281 Aug 10 '11 at 20:05