質問

私はSymfony 1.4をOrmとしてPropelで使用しています。 1時間ごとに郵送機能をトリガーするようにWebサーバースケジューラを構成しました。メールを送信するには、SymfonyのInbuild SwiftMailer(デフォルトで1.3,1.4)ではなく、PHP Swift Mailerクラスを使用しています。しかし、それを使用している間、私にエラーを与えています..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ジョブを通してメールを送信する他の方法はありますか?

役に立ちましたか?

解決

はい。 1.4本の関連部分を参照してください: タスクから電子メールを送信します.

他のヒント

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

 requiere_once dirname(__FILE__) . '/../vendor/symfony/lib/vendor/swiftmailer/swift_required.php
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top