0

私は symfony2 で 1 つのアプリケーションを開発しています。アプリケーションの片側でメールを送信していますが、これですべて問題ありません。しかし今、crontab で実行するコマンドを 1 つ作成しましたが、これはメールを送信しません。これが私のコマンドです: Doctrine\ORM\EntityManager を使用してください。Symfony\Component\Templating\EngineInterface を使用します。

クラス送信者{保護された$ em; 保護された $twig; 保護された $mailer; public function __construct($em, \Twig_Environment $twig, \Swift_Mailer $mailer) { $this->em = $em; $this->twig = $twig; $this->mailer = $mailer; }

public function runSender() {
    $proj = $this->em->createQuery ...
    $maillist = $this->em->createQuery ...
$templateFile = "projectprojBundle:MailList:emailNew.html.twig";
$templateContent = $this->twig->loadTemplate($templateFile);
$body = $templateContent->render(array('proj' => $proj));

    foreach ($maillist as $m) {
    $message = \Swift_Message::newInstance()->setSubject('New projects')
    ->setFrom('...')->setTo($m['email'])
    ->setContentType('text/html')
    ->setBody(trim($body));
    $this->mailer->send($message);
    } } }

すべてがクエリで問題ありません、私はテストしました。他のクラスから送信できる場合、なぜここで送信できないのですか?

4

2 に答える 2