PHP mail()表单没有';无法完成发送电子邮件

PHP mail()表单没有';无法完成发送电子邮件,php,forms,email,Php,Forms,Email,但这是由我在上面分享的链接的第2步引起的,它指示我添加以下内容: unknown: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all sendmail: warning: /etc/postfix/main.cf, line 676: overriding earlier entry: inet_protocols=ipv4 sendmail: warning: /etc/p

但这是由我在上面分享的链接的第2步引起的,它指示我添加以下内容:

unknown: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all
sendmail: warning: /etc/postfix/main.cf, line 676: overriding earlier entry: inet_protocols=ipv4
sendmail: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all
postdrop: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all
上面的第8行与inet_protocols=all冲突,因此我删除了上面的第8行,问题消失了,但无法发送邮件的原始问题仍然存在

  • 我没有使用错误抑制操作符
  • 我可能需要一些帮助来检查mail()是否返回true或false
  • 我检查了我试图发送邮件的电子邮件帐户的垃圾邮件文件夹
  • 我相信我已经提供了所有邮件标题:

    myorigin = live.com
    myhostname = smtp.live.com
    relayhost = smtp.live.com:587
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = noanonymous
    smtp_sasl_mechanism_filter = plain
    inet_protocols = ipv4
    smtp_use_tls = yes
    smtp_tls_security_level=encrypt
    tls_random_source=dev:/dev/urandom
    
  • 我尝试了多个电子邮件帐户,同样的问题

  • 我相信form方法与代码匹配
  • 我的MAMP Pro上的后缀不能解决问题吗
  • 我启用了PHP custom mail.log
  • 我是否应该放弃,使用不同的邮件程序或不同的方式用PHP开发我的联系人表单,这样就不会那么麻烦了
  • 因此,我相信我的问题并不是与其他相关帖子的重复,因为正如上面的大纲所示,我已经完成了该帖子的故障排除步骤,但它并没有解决我的问题


    我只能猜测,我的问题要么更具体到让后缀在我的MAMP Pro上工作。我没有检查mail()是否正确返回true或false,或者我可能需要使用PHPMailer或其他替代方法。

    查看SwiftMailer或PHPMailer可能会发现它的副本。但如果您是从本地主机发送邮件,则需要确保邮件服务器已安装并正在运行。@Qirel,那么可以使用MAMP或MAMP Pro发送邮件吗?我正试图确定我的障碍在哪里,因为我提供的主要链接看起来很可靠,但对我来说不起作用。
    mail.log
    PHP\u INI\u PERDIR
    ,因此不会受到
    INI\u set
    的影响。它的可能重复可能是研究SwiftMailer或PHPMailer的一个想法。但如果您是从本地主机发送邮件,则需要确保邮件服务器已安装并正在运行。@Qirel,那么可以使用MAMP或MAMP Pro发送邮件吗?我正试图确定我的障碍在哪里,因为我提供的要点链接看起来很可靠,但对我来说不起作用。
    mail.log
    PHP\u INI\u PERDIR
    ,因此不会受到
    INI\u set
    unknown: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all
    sendmail: warning: /etc/postfix/main.cf, line 676: overriding earlier entry: inet_protocols=ipv4
    sendmail: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all
    postdrop: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all
    
    myorigin = live.com
    myhostname = smtp.live.com
    relayhost = smtp.live.com:587
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = noanonymous
    smtp_sasl_mechanism_filter = plain
    inet_protocols = ipv4
    smtp_use_tls = yes
    smtp_tls_security_level=encrypt
    tls_random_source=dev:/dev/urandom
    
    // Set mail headers into a variable
                $headers  = "MIME-Version: 1.0\r\n";
                $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
                $headers .= "From: $name <$email> \r\n";
                $headers .= "X-Priority: 1\r\n"; 
                $headers .= "X-MSMail-Priority: High\r\n";
    
     // Send the email
     mail($to, $subject, $message, $headers);