Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
与'有关的问题;从';通过PHP mail()函数发送短信时的标题_Php_Email_Header_Sms - Fatal编程技术网

与'有关的问题;从';通过PHP mail()函数发送短信时的标题

与'有关的问题;从';通过PHP mail()函数发送短信时的标题,php,email,header,sms,Php,Email,Header,Sms,我正在使用PHP的mail()函数发送SMS消息。它工作正常,只是消息显示为来自'myuser@mr2.websitewelcome.com“当我想让它显示为”test@mydomain.com'. 以下是相关代码: //Set headers and send mail. $headers = "From: " . "test@mydomain.com" . "\r\n"; $headers .= "Reply-To: ". "test@mydomain.com" . "\r\n"; mai

我正在使用PHP的mail()函数发送SMS消息。它工作正常,只是消息显示为来自'myuser@mr2.websitewelcome.com“当我想让它显示为”test@mydomain.com'. 以下是相关代码:

//Set headers and send mail.
$headers = "From: " . "test@mydomain.com" . "\r\n";
$headers .= "Reply-To: ". "test@mydomain.com" . "\r\n";

mail( $from, '', $message, $headers );
我知道以前有人问过这个问题,但到目前为止没有任何帮助。我已尝试将标题设置为“-f”test@mydomain.com'. 不走运

顺便说一句,如果我发送到一个电子邮件地址,而不是一个电话号码,标题工作得很好

Idk,如果这与此有关,但我的脚本会从我在cpanel中设置的电子邮件转发器调用,如:

Address                 Forward To
test@mydomain.com       |/home/myuser/public_html/handler.php
此外,以下是发送到电子邮件地址的电子邮件的完整标题:

Return-Path: <itch3@mr2.websitewelcome.com>
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 <myemail@me.com>; 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 <myemail@me.com>; Wed,  8 Feb 2012 19:25:55 -0600 (CST)
Received: from itch3 by mr2.websitewelcome.com with local (Exim 4.69)
    (envelope-from <itch3@mr2.websitewelcome.com>)
    id 1RvIln-0003AQ-Cv
    for myemail@me.com; Wed, 08 Feb 2012 19:25:55 -0600
To: myemail@me.com
Subject: subject
From: "test@mydomain.com" <test@mydomain.com>
Reply-To: test@mydomain.com
Message-Id: <E1RvIln-0003AQ-Cv@mr2.websitewelcome.com>
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
返回路径:
收到:来自gateway01.websitewelcome.com(gateway01.websitewelcome.com[67.18.65.19])
通过mtain-mk01.r1000.mx.aol.com(互联网入站),ESMTP id为1B28B380008B
对于2012年2月8日星期三20:25:56-0500(美国东部时间)
接收:由gateway01.websitewelcome.com(后缀,来自userid 5007)
id A69B35C21D4BD;2012年2月8日星期三19:25:55-0600(CST)
收到:来自mr2.websitewelcome.com(mr2.websitewelcome.com[74.53.229.178])
通过gateway01.websitewelcome.com(后缀),ESMTP id为9CBAF5C21D49D
对于2012年2月8日星期三19:25:55-0600(CST)
收到:由mr2.websitewelcome.com和本地(Exim 4.69)从itch3发送
(信封来自)
id 1RvIln-0003AQ-Cv
对于myemail@me.com; 2012年2月8日星期三19:25:55-0600
致:myemail@me.com
主题:主题
来自:test@mydomain.com" 
答复:test@mydomain.com
消息Id:
日期:2012年2月8日星期三19:25:55-0600
X-反虐待:添加此标题是为了跟踪虐待行为,请将其包含在任何虐待报告中
X-Anti滥用:主主机名-mr2.websitewelcome.com
X-反滥用:原始域名-aol.com
X-反滥用:发起人/呼叫者UID/GID-[2146 32003]/[47 12]
X-Anti滥用:发件人地址域-mr2.websitewelcome.com
希特勒:没有
X-Source:/usr/bin/php
X-Source-Args:/usr/bin/php-q/home/itch3/public\u html/handler.php
X-Source-Dir:switchon3.com:/public\u html
X源发送方:
X-Source-Auth:3
X-电子邮件计数:2
X-Source-Cap:AXRJADM7Y3ZNCNVYNM7BXIYLNDLYNNPDGV3ZWXJB21LLMNVBQ==
x-aol-global-disposition:G
X-AOL-SCOLL-SCORE:0:2:199012208:93952408
X-AOL-SCOLL-URL\u计数:0
x-aol-sid:3039ac1d61854f3320a4018d
X-AOL-IP:67.18.65.19
X-AOL-SPF:域:mr2.websitewelcome.com SPF:无

能否使用附加参数参数参数(再次)声明发件人地址

mail('nobody@example.com', 'the subject', 'the message',
"From: webmaster@example.com\r\n", '-fwebmaster@example.com');

我通常在使用mail()时添加额外的参数,它可以解决我遇到的大多数问题。

您可以将返回路径设置为
test@mydomain.com
,就像这样:

mail( $from, '', $message, $headers, '-ftest@mydomain.com');

(注意
-f
后面缺少空格)

未设置变量$from,因此它是默认值。您的代码应该是:

//Set headers and send mail.
$headers = "From: " . "test@mydomain.com" . "\r\n";
$headers .= "Reply-To: ". "test@mydomain.com" . "\r\n";

$from = "test@mydomain.com";

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

我在想,你是如何通过
mail()
发送短信的?@Vyktor:大多数运营商都会将电子邮件地址映射到手机号码,例如Verizon使用
yournumber@vtext.com
。您能否发布一封普通(非短信)电子邮件的完整标题(收到时)?我们可以看看是否有明显无效的东西。(即使某些邮件客户端理解它应该是什么,它可能仍然无效)。@user617123它需要是完整的标题。有关在某些主要邮件客户端中获取它们的说明,请参见此链接:@user617123如果设置了主题,预期的“发件人”地址是否显示?(tbh,那是在黑暗中拍摄的)。我现在相当确信这取决于你的回归路径(这是最有可能的情况)。如果运行
mail($from,,$message,$headers,,,则返回路径是否在标题中更改-ftest@mydomain.com');
(注意
-f