最近我在研究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');
我应该纠正什么才能高效运行
最佳答案
创建一个单独的 PHP 脚本来执行后台工作,并在您的主脚本中调用该脚本。关键是 & 符号!
<?php
$command = "/usr/bin/php5 -f /var/www/my/php/file.php";
exec( "$command > /dev/null &", $arrOutput );
?>
关于php - 想在php后台发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12072851/