想在php的后台发送电子邮件

时间:2012-08-22 12:10:27

标签: php symfony redis

最近我正在研究symfony。我创建了一个简单的表单,并希望提交该表单并将响应发送给用户作为电子邮件。

index我写了如下:

    $product=new Product();
    $product->setName('rohit');
    $product->setPass('rohit');

    $form=$this->createFormBuilder($product)
    ->add('name','text')
    ->add('pass','password')
    ->getForm();

    $name='rohit';
        return $this->render('EnsNewBundle:Email:ind.html.twig',
    array('form'=>$form->createView(),'name'=>$name));

当我提交此表单时,应执行以下操作:

i)它应该打印hello和 ii)电子邮件流程应在后台运行。

我想写如下:

$client = new \Predis\Client();

      $client->lpush('emailid','ucerturohit@gmail.com');

      $u=$client->lrange('emailid',0,10);
  //notification_on_signup($u);

     var_dump($u);

    return $this->render('EnsNewBundle:Email:header.html.twig');

我应该纠正什么才能有效地运作

1 个答案:

答案 0 :(得分:0)

创建一个单独的PHP脚本来完成后台工作,并在主脚本中调用此脚本。关键是& amp sign!

<?php
$command = "/usr/bin/php5 -f /var/www/my/php/file.php";

exec( "$command > /dev/null &", $arrOutput );
?>