2012-02-08 63 views
1

我使用PHP的mail()函數發送SMS消息。它工作正常,只是當我希望它顯示爲'[email protected]'時,該消息顯示爲來自'[email protected]'。這裏是相關的代碼:通過PHP郵件()函數發送短信時發送'From'標題問題

//Set headers and send mail. 
$headers = "From: " . "[email protected]" . "\r\n"; 
$headers .= "Reply-To: ". "[email protected]" . "\r\n"; 

mail($from, '', $message, $headers); 

我知道這個問題已被問過,但迄今沒有任何幫助。我試着將頭部設置爲'-f [email protected]'。沒有運氣。

順便說一句,如果我發送到一個電子郵件地址而不是電話號碼,頭文件工作得很好。

IDK如果這有什麼關係,但我的腳本會從我在喜歡的cPanel設置電子郵件轉發叫:

Address     Forward To 
[email protected]  |/home/myuser/public_html/handler.php 

此外,這裏有一個電子郵件的完整標題發送到一個電子郵件地址:

Return-Path: <[email protected]> 
Received: from gateway01.websitewelcome.com (gateway01.websitewelcome.com [67.18.65.19]) 
    by mtain-mk01.r1000.mx.aol.com (Internet Inbound) with ESMTP id 1B28B3800008B 
    for <[email protected]>; Wed, 8 Feb 2012 20:25:56 -0500 (EST) 
Received: by gateway01.websitewelcome.com (Postfix, from userid 5007) 
    id A69B35C21D4BD; Wed, 8 Feb 2012 19:25:55 -0600 (CST) 
Received: from mr2.websitewelcome.com (mr2.websitewelcome.com [74.53.229.178]) 
    by gateway01.websitewelcome.com (Postfix) with ESMTP id 9CBAF5C21D49D 
    for <[email protected]>; Wed, 8 Feb 2012 19:25:55 -0600 (CST) 
Received: from itch3 by mr2.websitewelcome.com with local (Exim 4.69) 
    (envelope-from <[email protected]>) 
    id 1RvIln-0003AQ-Cv 
    for [email protected]; Wed, 08 Feb 2012 19:25:55 -0600 
To: [email protected] 
Subject: subject 
From: "[email protected]" <[email protected]> 
Reply-To: [email protected] 
Message-Id: <[email protected]> 
Date: Wed, 08 Feb 2012 19:25:55 -0600 
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report 
X-AntiAbuse: Primary Hostname - mr2.websitewelcome.com 
X-AntiAbuse: Original Domain - aol.com 
X-AntiAbuse: Originator/Caller UID/GID - [2146 32003]/[47 12] 
X-AntiAbuse: Sender Address Domain - mr2.websitewelcome.com 
X-BWhitelist: no 
X-Source: /usr/bin/php 
X-Source-Args: /usr/bin/php -q /home/itch3/public_html/handler.php 
X-Source-Dir: switchon3.com:/public_html 
X-Source-Sender: 
X-Source-Auth: itch3 
X-Email-Count: 2 
X-Source-Cap: aXRjaDM7Y3ZncnViYnM7bXIyLndlYnNpdGV3ZWxjb21lLmNvbQ== 
x-aol-global-disposition: G 
X-AOL-SCOLL-SCORE: 0:2:199012208:93952408 
X-AOL-SCOLL-URL_COUNT: 0 
x-aol-sid: 3039ac1d61854f3320a4018d 
X-AOL-IP: 67.18.65.19 
X-AOL-SPF: domain : mr2.websitewelcome.com SPF : none 
+0

我很徘徊,你怎麼通過'mail()發送短信? – Vyktor 2012-02-08 23:49:55

+1

@Vyktor:大部分運營商都會將電子郵件地址映射到手機號碼,例如,Verizon使用'yournumber @ vtext.com'。 – webbiedave 2012-02-08 23:52:32

+0

您可以發佈正常(非短信)電子郵件的完整標題(收到)嗎?我們可以看看是否有什麼顯然是無效的。 (即使某些郵件客戶端了解它應該是什麼,它仍然可能是無效的)。 – SimonMayer 2012-02-09 00:28:27

回答

5

您可以使用附加參數參數來(再次)聲明發件人地址嗎?

mail('[email protected]', 'the subject', 'the message', 
"From: [email protected]\r\n", '[email protected]'); 

我一般)上添加附加參數使用電子郵件(時,它往往解決我所經歷的大多數問題。