Domanda

Sto usando Symfony 1.4 con Propel come ORM. Ho utilità di pianificazione del server Web configurato per attivare una funzione di mailing ad ogni 1 ora. Per mail di invio sto usando PHP Swift Mailer di classe, e non inbuild Swiftmailer del symfony (impostazione predefinita in 1.3,1.4). Ma durante l'utilizzo mi sta dando l'errore .. come "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". Il codice che sto utilizzando ...

  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);

c'è qualche altro modo per inviare la posta attraverso posti di lavoro Cron ??

È stato utile?

Soluzione

Sì. Vedere la parte rilevante del libro 1.4: L'invio di un'email da un compito .

Altri suggerimenti

Il problema è perché è necessario aggiungere questo riferimento nel vostro compito cosí:

 requiere_once dirname(__FILE__) . '/../vendor/symfony/lib/vendor/swiftmailer/swift_required.php
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top