sendmail -s me@example.com
Subject:Salem
This is body of email
Ctrl+D之上的Shell脚本在RHEL-7下工作良好的。
我们现在需要用php包装这个命令行( sendmail ),以获得如下内容:
<?php
sendmail('from@example.com',"this is title","blablalb","to@example.com")
?>怎么做?是否应该在RHEL下安装PHP库,以便能够通过PHP在sendmail通信线路上中继发送电子邮件?
但是,在programming语言的上下文中,已经发布了相同的问题,这就是the best answer,直到现在:
def sendMail():
sendmail_location = "/usr/sbin/sendmail" # sendmail location
p = os.popen("%s -t" % sendmail_location, "w")
p.write("From: %s\n" % "from@somewhere.com")
p.write("To: %s\n" % "to@somewhereelse.com")
p.write("Subject: thesubject\n")
p.write("\n") # blank line separating headers from body
p.write("body of the mail")
status = p.close()
if status != 0:
print "Sendmail exit status", status发布于 2016-05-26 14:36:21
你可以使用系统
$command = '/usr/sbin/sendmail -t -f sender@example.com < /email.txt';
system($command);
https://stackoverflow.com/questions/37463772
复制相似问题