2010-06-29 56 views
3

我使用郵件功能如下:PHP郵件功能不發送電子郵件至有效帳戶相同的域

mail($emailto, $subject, $body, $headers); 
mail('[email protected]', $subject.'/'.$emailto, $body, $headers); 

第一個適用於終端用戶。第二份是爲了記錄保存目的。

有時enduser指定他們的電子郵件地址,其他時間是空白。

  1. 當指定的電子郵件地址,最終用戶actuallys得到的電子郵件沒有任何問題
  2. 然而,沒有電子郵件獲取這兩種情況下發送到[email protected] - 我檢查垃圾郵件文件夾,好。

在my/mail/new文件夾中,我看到了許多與下面類似的文件。錯誤是不正確的,因爲[email protected]是一個有效的電子郵件地址(使用谷歌的域名設置)。

Return-path: <> 
    Envelope-to: [email protected] 
    Delivery-date: Mon, 28 Jun 2010 12:37:28 -0400 
    Received: from mailnull by myhostingprovider.com with local (Exim 4.69) 
     id UNIQUEIDZ-7x 
     for [email protected]; Mon, 28 Jun 2010 12:37:28 -0400 
    X-Failed-Recipients: [email protected] 
    Auto-Submitted: auto-replied 
    From: Mail Delivery System <[email protected]> 
    To: [email protected] 
    Subject: Mail delivery failed: returning message to sender 
    Message-Id: <[email protected]> 
    Date: Mon, 28 Jun 2010 12:37:28 -0400 

    This message was created automatically by mail delivery software. 

    A message that you sent could not be delivered to one or more of its 
    recipients. This is a permanent error. The following address(es) failed: 

    [email protected] 
     No Such User Here 

    ------ This is a copy of the message, including all the headers. ------ 

    Return-path: <[email protected]> 
    Received: from nobody by myhostingprovider.com with local (Exim 4.69) 
     (envelope-from <[email protected]>) 
     id UNIQUEIDV-6b 
     for [email protected]; Mon, 28 Jun 2010 12:37:28 -0400 
    To: [email protected] 
    Subject: mysite.com: SUBJECT/[email protected] 
    X-PHP-Script: www.mysite.com/mysitescript.php for IPADDRESS 
    MIME-Version: 1.0 
    Content-type: text/html; charset=UTF-8 
    From: mysite.com Service <[email protected]> 
    Message-Id: <[email protected]> 
    Date: Mon, 28 Jun 2010 12:37:28 -0400 
+0

您是否確實驗證過電子郵件地址有效? – 2010-06-29 05:53:21

+0

是的,電子郵件地址是有效的,沒有問題發送/接收通過普通的電子郵件客戶端... – Dave 2010-07-01 10:01:49

回答

0

你能使用普通的電子郵件客戶端(網頁一個如Hotmail/Gmail或展望/雷鳥)發送電子郵件至該地址?

如果您不能 - 您的電子郵件帳戶設置不正確。

如果可以 - 您的電子郵件帳戶被設置爲忽略您的域或類似的東西(也許垃圾郵件過濾器假裝用戶不存在?)。

5

兩件事情:

  1. 你應該檢查,看看是否$emailto實際上是調用mail函數之前的空白。您不希望PHP嘗試將郵件發送到空白地址。

  2. 您與[email protected]未傳遞的問題可能是你本地的網站主機(mysite.com)試圖將郵件傳遞到它認爲「本地」地址的結果 - 因爲它是在同一個域,而實際上該電子郵件存在於Google Apps中。你的郵件服務器(如postfix或sendmail)應該有一個設置來禁用這個「快捷方式」。

+0

.............是...第二點聽起來像它...我' m在一個共享服務器託管 - 如何/我在哪裏尋找這個「選項」?提供商也給我們cpanel訪問權限(除了shell帳戶) – Dave 2010-06-29 06:15:44

+2

嘗試cPanel - > MX條目 - >電子郵件路由 - >遠程郵件交換器。不要忘記upvote有用的答案,並標記一個正確的:) – philfreo 2010-07-04 06:31:04

+0

這是完美的,謝謝。 – 2012-08-27 21:43:28

0

如果您正在使用sendmail的去配置文件,並使用MX記錄指向谷歌Apps的像我這樣做,做到以下幾點:

sudo vim /etc/mail/sendmail.mc 

補充一點:

FEATURE(`relay_based_on_MX')dnl 

重新啓動發送郵件

sudo /etc/init.d/sendmail restart 
相關問題