0
symfony 1.4.11을 사용하고 작업에서 메일을 보내야합니다. 나는 this 기사를 사용합니다. 그래서 예를 들어 다음의 간단한 코드가 있습니다 오류없이Symfony task mailing
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('[email protected]', '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);
}
}
그래서 작업 일을, 내가 가진 :
>> 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',)
을하지만 편지가 내 이메일에 co.kr에서하지 않습니다 ... 어쩌면 내가 잘못된 코드가? 이 문서 밖으로
그는 기본적으로 dev에서 실행 중이며 기본 전략에는 none이 있습니다. 그는 찌푸린 환경에서 그것을 실행해야합니다. – Maerlyn
나는 어리 석다. 예, 저는 dev_not 전략에서 ** delivery_strategy **에 있습니다. 그리고 내 dev에 실행중인 작업. – denys281