郵件可以從終端機運行,但不能從瀏覽器運行

郵件可以從終端機運行,但不能從瀏覽器運行

我使用的是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 發送郵件

相關內容