如何用exec命令支持PHP变量?

时间:2016-05-17 11:46:11

标签: php linux bash shell

你好我从php发送邮件。我正在从数据库中获取地址和cc地址并将它们存储在一个变量中。 $ to,$ cc我需要在mailx命令中使用它。 以下查询是硬编码的并且正在运行。

 exec('echo "hey i am there" | mailx -S smtp=10.0.8.8:25 -r support@gmail.com -s "Alert" pratik@gmail.com');

需要更换

 $message = hey i am there
 $to=pratik@gmail.com
 $from =support@gmail.com 
 $subject = Alert

exec('echo $message | mailx -S smtp=10.0.8.8:25 -r $from  -s $subject $to');

但是上面的东西不起作用

2 个答案:

答案 0 :(得分:4)

只需将'更改为"

即可
exec("echo $message | mailx -S smtp=10.0.8.8:25 -r $from  -s $subject $to");

答案 1 :(得分:2)

你应该连接你的字符串。

jspm bundle app/bootstrap mybundlename.js