2012-04-16 3 views
1

Symfony의 관리자 패널에서 이메일 구성을 어떻게 할 수 있습니까? 기본 내가 파일 factories.yml이를 설정해야합니다Symfony 1.4의 구성 메일러 - factories.yml이 아닌 admin 패널에서 어떻게 사용합니까?

mailer: 
    class: sfMailer 
    param: 
    logging:   %SF_LOGGING_ENABLED% 
    charset:   %SF_CHARSET% 
    delivery_strategy: realtime 
    transport: 
     class: Swift_SmtpTransport 
     param: 
     host:  localhost 
     port:  25 
     encryption: ~ 
     username: ~ 
     password: ~ 

내가 관리자 패널에서 설정 호스트, 포트, 암호화, 사용자 이름과 비밀번호를 좋아하고 내 데이터베이스에서이 작업을 계속합니다. 메일을 보내면 어떻게 데이터베이스에서이 데이터를 가져올 수 있습니까?

$message = $this->getMailer()->compose(
     array('[email protected]' => 'Jobeet Bot'), 
     $affiliate->getEmail(), 
     'Jobeet affiliate token', 
     <<<EOF 
Your Jobeet affiliate account has been activated. 

Your token is {$affiliate->getToken()}. 

The Jobeet Bot. 
EOF 
    ); 

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

나는이 데이터를 데이터베이스에서 얻을 수 있지만 :) 나는 getMailer()에 쓰는 방법을 모른다.

답변

4

이벤트가 발생했습니다 when the mailer is configured.

$dispatcher->notify(new sfEvent($this, 'mailer.configure')); 

그래서 당신은 add a listener이 이벤트에, 메일러 개체를 검색 할 수 있고, 그것을 재 - 구성합니다. 이 조각의 설명으로

은 또는, 당신은 우편물에 수동으로 전화를 내장하고 설정을 설정하는 방법을 정의 (및 작업에 getMailer를 사용할 수있는 장점이있어) 할 수 있습니다 http://snippets.symfony-project.org/snippet/377

관련 문제