简体   繁体   English

用php邮件发送的邮件未显示

[英]Mail sent with php mail not showing up

I have recently changed my OS from Ubuntu 11.10 to Debian 7.0.0 due to some problems I was having with Ubuntu. 由于我在Ubuntu上遇到的一些问题,最近我已将操作系统从Ubuntu 11.10更改为Debian 7.0.0。 I have set up LAMP using Apache 2. Most things appear to be working about the same but mail, which was working fine on Ubuntu, is now not working properly. 我已经使用Apache 2设置了LAMP。大多数情况似乎都差不多,但是在Ubuntu上可以正常工作的邮件现在无法正常工作。 I use the following code. 我使用以下代码。

    $mailDelivery=mail($to,$subject,$message,$headers);
    if ($mailDelivery)
    {
        ?>
        <script type="text/javascript">
        alert("Mail delivery successful");
        </script>
        <?php
    }
    else
    {
        ?>
        <script type="text/javascript">
        alert("Mail delivery failed");
        </script>
        <?php
    }

I checked the input arguments to mail() and they are the same as the ones that worked successfully on Ubuntu. 我检查了mail()的输入参数,它们与在Ubuntu上成功运行的参数相同。 Also, the alert box returns 此外,警报框还会返回

Mail delivery successful

However, the mail does not show up at the address (which is one of my on-line addresses). 但是,该邮件未显示在该地址(这是我的在线地址之一)上。

I looked at php.ini and it has the following lines 我看着php.ini,它具有以下几行

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

There is nothing about mail delivery in /var/log/apache2/error.log. /var/log/apache2/error.log中没有关于邮件传递的任何内容。

I also checked my spam folder at the destination email address and there was nothing there. 我还检查了目标电子邮件地址中的垃圾邮件文件夹,那里什么也没有。

I also transferred the iptables from Ubuntu to Debian by doing 我还通过执行以下操作将iptables从Ubuntu转移到Debian

iptables-save >iptables.save

on Ubuntu, copying iptables.save over and 在Ubuntu上,将iptables.save复制并

iptables-restore <iptables.save

I also did the following calls with the following results. 我还进行了以下调用,结果如下。

peter@app-server:/var/www$ sudo cat /var/log/mail.err
peter@app-server:/var/www$ sudo cat /var/log/mail.log
peter@app-server:/var/www$ sudo cat /var/log/mail.warn
peter@app-server:/var/www$ sudo cat /var/log/mail.info
peter@app-server:/var/www$ 

OK. 好。 I found the source of my problem. 我找到了问题的根源。 I had not installed the SMTP server. 我尚未安装SMTP服务器。 I ran 我跑了

sudo apt-get install postfix

and that fixed the problem. 这样就解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM