1

Symfony 1.4 と Propel を ORM として使用しています。1時間ごとにメール機能をトリガーするようにWebサーバースケジューラを構成しました。メールを送信するために、symfony の組み込み Swiftmailer (1.3、1.4 のデフォルト) ではなく、PHP Swift メーラー クラスを使用しています。しかし、使用中にエラーが発生しています..「Catchable fatal error: Argument 1 passed to Swift_Transport_EsmtpTransport::__construct() must implement interface Swift_Transport_IoBuffer, none given in /home/msconslt/sfprojects/test/lib/mailClasses/classes/Swift/Transport/EsmtpTransport.php on line 64」として。私が使用しているコード...

  require_once(dirname(__FILE__).'/../../config/ProjectConfiguration.class.php');
  $configuration =ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true);
  // Remove the following lines if you don't use the database layer
  $databaseManager = new sfDatabaseManager($configuration);

 //Create the Transport
 $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
 ->setUsername('myid@gmail.com')
 ->setPassword('mypassword')
 ;

//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

 //Create a message
 $message = Swift_Message::newInstance("Test Mail")
 ->setFrom(array('myid@gmail.com' => 'Harry'))
->setTo(array('someid@gmail.com'))
->setBody('<html>'.
 '<head></head>'.
 '<body> <span>Dear, </span><br/> Hi there..</body>'.
 '</html>',
 'text/html'
 );

 $mailer->send($message);

Cronジョブを介してメールを送信する他の方法はありますか??

4

2 に答える 2

2

はい。1.4 ブックの関連部分を参照してください: Sending an email from a task .

于 2010-11-01T21:20:03.500 に答える
1

この問題は、この参照を taks に追加する必要があるためです。

 requiere_once dirname(__FILE__) . '/../vendor/symfony/lib/vendor/swiftmailer/swift_required.php
于 2012-01-12T14:21:23.700 に答える