新的 CentOS 7 伺服器 - 從 PHP 應用程式發送郵件

新的 CentOS 7 伺服器 - 從 PHP 應用程式發送郵件

對於新手問題表示歉意,但我希望有人可以為我提供一些幫助/步驟。

我正在將網站從託管共享託管帳戶在線遷移到新的作業系統7雲端伺服器。除了嘗試從 PHP 腳本發送電子郵件之外,一切似乎都運作良好。在設定 CentOS 伺服器時,我沒有配置任何郵件應用程式等。

我假設這是因為我還沒有安裝某些東西。任何人都可以建議我如何設定伺服器以從 PHP 應用程式發送電子郵件(我不想設定完整的郵件伺服器,因為這是透過 Office365 管理的)

我嘗試發送測試,它所做的一切都是向我發送一條訊息/var/spool/郵件

任何幫助/建議都會很棒!(以下 /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--

答案1

您仍然需要配置某物處理電子郵件。

最簡單的方法可能是配置您正在使用的任何 MTA,以便將其更改[email protected](php 最終使用的電子郵件地址)為您想要使用的任何郵件地址。

由於您似乎正在使用 Postfix,因此您應該檢查一下Postfix 官方文件中的部分說明如何做到這一點。

答案2

Wouter 說您需要 mta 是正確的,postfix 是一個不錯的選擇,但是在花費大量時間配置它之前,您應該檢查一下您的努力不會白費。

  • 您的伺服器可以解析主機名稱(嘗試使用 nslookup)嗎?
  • 它可以透過連接埠 25 與外界建立連線(嘗試使用 telnet)嗎?
  • 是否啟用了selinux?

禁用selinux 可能看起來有點笨拙和不明智,但是,雖然RH7 類型策略是6.5 的改進,但SElinux 和RH 策略確實很糟糕,並且除了在其他方面付出了巨大的努力之外,幾乎沒有增加任何安全優勢,而且付出了可怕的代價。

相關內容