新的CentOS 7服务器 – 从PHP应用程序发送邮件

道歉为新手问题,但我希望有人可以提供一些帮助/步骤。

我正在将网站从托pipe共享主机帐户在线迁移到新的CentOS 7云服务器。 除了尝试从PHP脚本发送电子邮件之外,一切看起来都是完美的。 在设置CentOS服务器时,我没有configuration任何邮件应用程序等。

我假设这是因为我没有安装的东西。 任何人都可以build议如何设置服务器从PHP应用程序发送电子邮件(我不想设置一个完整的邮件服务器,因为这是通过Office365pipe理)

我试着发送一个testing,并把它发送给/ var / spool / mail

任何帮助/build议将是伟大的! (从/ var / spool / mail /下面输出)


--0AEF.1434711105/testserver1.localdomain Content-Description: Delivery report Content-Type: message/delivery-status Reporting-MTA: dns; testserver1.localdomain X-Postfix-Queue-ID: 0AEF X-Postfix-Sender: rfc822; [email protected] Arrival-Date: Fri, 19 Jun 2015 06:51:44 -0400 (EDT) Final-Recipient: rfc822; [email protected] Action: failed Status: 5.0.0 Remote-MTA: dns; googlemail.com Diagnostic-Code: smtp; 550-Verification failed for <[email protected]> 550-The mail server could not deliver mail to [email protected]. The account or domain may not exist, they may be blacklisted, or missing the proper dns entries. 550 Sender verify failed --0AEF.1434711105/testserver1.localdomain Content-Description: Undelivered Message Content-Type: message/rfc822 Return-Path: <[email protected]> Received: by testserver1.localdomain (Postfix, from userid 48) id 0AEF; Fri, 19 Jun 2015 06:51:44 -0400 (EDT) To: [email protected] Subject: My subject X-PHP-Originating-Script: 0:index.php Message-Id: <[email protected]> Date: Fri, 19 Jun 2015 06:51:44 -0400 (EDT) From: [email protected] (Apache) First line of text Second line of text --0AEF.1434711105/testserver1.localdomain-- 

你仍然需要configuration一些东西来处理电子邮件。

最简单的方法是configuration你正在使用的任何MTA,以便将[email protected] (php最终使用的电子邮件地址)更改为您要使用的任何邮件地址。

由于您似乎在使用Postfix,因此您应该在官方的Postfix文档中查看这个部分,它解释了如何做到这一点。

Wouter是正确的说你需要一个mta,那个postfix是一个不错的select,但是在花费大量时间configuration它之前,你应该检查你的努力是不是徒劳的。

  • 你的服务器可以parsing主机名(用nslookup试试)?
  • 它可以连接到外部世界的端口25(尝试与远程login)?
  • 启用了selinux?

禁用selinux可能看起来有点笨拙和不明智,但是,虽然RH7types的政策是对6.5的改进,但是SElinux和RH的政策确实是非常可怕的,并且增加了非常小的安全优势,一个静态内容服务器。