0
sendmail -s me@example.com
Subject:Salem
This is body of email
Ctrl+D

上記のシェル スクリプトは RHEL-7 で正常に動作します。

このコマンド ライン ( sendmail) を php でラップして、次のようにする必要があります。

  <?php 
       sendmail('from@example.com',"this is title","blablalb","to@example.com") 
   ?>

方法 ?sendmail コマンドラインで PHP リレーによって電子メールを送信できるようにするには、RHEL に PHP ライブラリをインストールする必要がありますか?


ただし、Python プログラミング言語のコンテキストで同じ質問が投稿されていることがわかっており、これが今までの最良の回答です。

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
4

1 に答える 1

0

システムをご利用いただけます

$command = '/usr/sbin/sendmail -t -f sender@example.com < /email.txt';
system($command);

于 2016-05-26T14:36:21.420 に答える