php 能运行 linux 代码吗

2016-07-30 11:32:06 +08:00
 c7898585

需要用 php 运行下面的代码

sendmail -t >/dev/null 2>&1 <<EOF
to:receiver@exmaple.com
from:sender@example.com subject:我是测试 我是测试 EOF

3134 次点击
所在节点    Linux
13 条回复
RIcter
2016-07-30 11:36:16 +08:00
phperstar
2016-07-30 11:36:22 +08:00
弄个 sh 脚本吧,然后用 php exec 函数执行这个脚本吧
c7898585
2016-07-30 11:50:55 +08:00
@phperstar
exec 这个函数没看懂额。。。
skydiver
2016-07-30 11:52:24 +08:00
phperstar
2016-07-30 11:54:10 +08:00
@c7898585 http://php.net/manual/zh/book.exec.php 放着这么好的手册不看,太浪费呀。。。
UnisandK
2016-07-30 11:55:21 +08:00
用 mailgun 多好
c7898585
2016-07-30 12:00:30 +08:00
@skydiver 会有代发
90safe
2016-07-30 12:18:52 +08:00
shell_exec("sendmail -t >/dev/null 2>&1 <<EOF")
exec("sendmail -t >/dev/null 2>&1 <<EOF")
一般网站禁用 exec 函数,推荐前者。
90safe
2016-07-30 12:20:57 +08:00
http://www.jb51.net/article/28241.htm
四个执行命令的函数,不谢
Tink
2016-07-30 12:26:59 +08:00
exec
sneezry
2016-07-30 12:31:54 +08:00
用 mailgun 吧,每月 10000 封免费,自己的 mail server 多数会进垃圾箱
c7898585
2016-07-30 14:58:03 +08:00
@phperstar sender 和 receiver 是变量额
通过 PHP 传递的
这用 sh 的话只能做定量吧
KomeijiSatori
2016-07-31 08:47:02 +08:00
system();

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/295968

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX