メールは端末からは機能しますが、ブラウザからは機能しません

メールは端末からは機能しますが、ブラウザからは機能しません

私は ubuntu 14.04 を使用しています。{sudo apt-get install postfix} を使用して postfix をインストールしました。正常にインストールされました。ターミナルを使用してメールを送信しようとすると、メールが宛先に送信されていることが分かりました。しかし、/var/www/html/mailsend.php から送信しようとすると、メールが送信されないことが分かりました。これが私の main.cf コードです:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#@raaj
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
#@raaj
#smtpd_banner = $myhostname ESMTP $mail_name yslserver
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = yslserver
#@raaj
#mydomain = localhost
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
#akk
myhostname = yslserver
mydomain = localhost
myorigin = $mydomain

default_destination_concurrency_limit = 4
soft_bounce = yes

mydestination = $myhostname, rajkhurana, yslserver, localhost.localdomain, ,localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = 
inet_interfaces = all
inet_protocols = all
#@raaj
#mailbox_command = procmail -a "$EXTENSION"

私は次のコードを使用しています:

<?php
//if "email" variable is filled out, send email
  if (isset($_REQUEST['sendmail']))  {
      //Email information
      $mailFrom = "[email protected]";
      $mailTo = $_REQUEST['mailto'];
      $subject = $_REQUEST['subject'];
      $comment = $_REQUEST['comment'];
      //print_r($_POST);
      //send email
    if (mail($mailTo, "$subject", $comment, "From: " . $mailFrom)){
        echo "Thanks, mail has sent successfully";
    }
    else {
        //Email response
        echo "Mail could not sent..!";
      }
  }
  //if "email" variable is not filled out, display the form
 else { ?>


<html>
    <head>
<style>
    #main {
        width:300px;
        height:auto;
        background-color:#D5CADA;
        padding:10px;
        margin:10px;
        }
    .section {
        width:290px;
        height:auto;
        }
</style>
    </head>
    <body>
<div id="main">
     <form method="post" action="">
        <div class="section">
              Email To: <input name="mailto" id ="mailto" type="text" /><br />
              Subject: <input name="subject" type="text" /><br />
              Message:<br />
              <textarea name="comment" rows="7" cols="33"></textarea><br />
              <div>
              <input type="submit" name="sendmail" id="sendmail" value="Submit" />
              <input type="reset" name="reset" id="reset" value="Reset"/>
              </div>
      </div>
      </form>
  </div>
  </body>
  </html>

<?php } ?>

この問題をどのように解決すればよいか教えてください。

答え1

コマンドラインから動作しているので、PHP の問題のようです。php.ini ファイルで sendmail パスを定義しましたか?

この投稿を見るPHP、LAMPP、PostFix でメールを送信する

関連情報