Symfony1 Symfony任务邮寄
我使用symfony 1.4.11,我需要从任务中进行邮件发送。我用冠词。下面是一个简单的代码,例如:Symfony1 Symfony任务邮寄,symfony1,swiftmailer,symfony-1.4,mailing,Symfony1,Swiftmailer,Symfony 1.4,Mailing,我使用symfony 1.4.11,我需要从任务中进行邮件发送。我用冠词。下面是一个简单的代码,例如: class mailerSendTask extends sfBaseTask { protected function configure() { $this->addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, '
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);
}
}
但是这些信件与我的电子邮件不一致……也许我的代码不正确?请查看本文:
也许您已经在dev
或test
环境中将delivery\u策略设置为none
。查看本文:
可能您已经在dev
或test
环境中将delivery\u策略设置为none
。默认情况下,他在dev中运行它,默认策略没有。他应该在prod环境下运行它。我很愚蠢。是的,我在dev none策略中有交付策略。我的任务在dev中运行。默认情况下,他在dev中运行它,默认策略没有。他应该在prod环境下运行它。我很愚蠢。是的,我在dev none策略中有交付策略。我的任务在dev中运行。
>> 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',)