메일이 터미널에서는 작동하지만 브라우저에서는 작동하지 않습니다.

메일이 터미널에서는 작동하지만 브라우저에서는 작동하지 않습니다.

우분투 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를 사용하여 메일 보내기

관련 정보