使用PHP curl在Amazon SES上创建x-Header或自定义电子邮件标题
我正在尝试让自定义电子邮件头工作(x-header),而不是使用AmazonSDK,而是使用curl使用PHP curl在Amazon SES上创建x-Header或自定义电子邮件标题,php,curl,amazon-ses,email-headers,Php,Curl,Amazon Ses,Email Headers,我正在尝试让自定义电子邮件头工作(x-header),而不是使用AmazonSDK,而是使用curl $headers = array(); $headers[] = 'Date: '.$date; $headers[] = 'Host: '.$this->ses->getHost(); $auth = 'AWS3-HTTPS AWSAccessKeyId='.$this->ses->getAccessKey(); $auth .= ',Algorithm=HmacSH
$headers = array();
$headers[] = 'Date: '.$date;
$headers[] = 'Host: '.$this->ses->getHost();
$auth = 'AWS3-HTTPS AWSAccessKeyId='.$this->ses->getAccessKey();
$auth .= ',Algorithm=HmacSHA256,Signature='.$this->__getSignature($date);
$headers[] = 'X-Amzn-Authorization: '.$auth;
正在尝试将此添加到此处
$headers[] = 'X-CampaignId: ' . $campaignId
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
头不断被剥掉
自定义标题是否仅支持Amazon的SDK?
这篇文章似乎表明:
使用
curl_setopt($curl, CURLOPT_VERBOSE, true)
这就是curl中发生的情况
* About to connect() to email.us-east-1.amazonaws.com port 443
* Trying <ip address>... * connected
* Connected to email.us-east-1.amazonaws.com (<ip address>) port 443
* successfully set certificate verify locations:
* CAfile: <somefile>.crt
CApath: none
* SSL connection using RC4-MD5
* Server certificate:
* subject: /C=US/ST=Washington/L=Seattle/O=Amazon.com Inc./CN=email.us-east-1.amazonaws.com
* start date: 2013-07-17 00:00:00 GMT
* expire date: 2014-07-18 23:59:59 GMT
* subjectAltName: email.us-east-1.amazonaws.com matched
* issuer: /C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)10/CN=VeriSign Class 3 Secure Server CA - G3
* SSL certificate verify ok.
> POST / HTTP/1.1
User-Agent: SimpleEmailService/php
Accept: */*
Date: Tue, 21 Jan 2014 19:25:04 UTC
Host: email.us-east-1.amazonaws.com
X-Amzn-Authorization: <the key string>
X-CKCampaign: newYear2014
Comments: newYear2014
Return-Path: newYear2014
Content-Type: application/x-www-form-urlencoded
Content-Length: 45171
Expect: 100-continue
< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< x-amzn-RequestId: <string>
< Content-Type: text/xml
< Content-Length: 326
< Date: Tue, 21 Jan 2014 19:25:04 GMT
* Connection #0 to host email.us-east-1.amazonaws.com left intact
* Closing connection #0
*即将连接()到email.us-east-1.amazonaws.com端口443
*正在尝试…*有联系的
*已连接到email.us-east-1.amazonaws.com()端口443
*已成功设置证书验证位置:
*CAfile:.crt
卡帕斯:没有
*使用RC4-MD5的SSL连接
*服务器证书:
*主题:/C=US/ST=Washington/L=西雅图/O=Amazon.com公司/CN=email.US-east-1.amazonaws.com
*开始日期:2013-07-17 00:00:00 GMT
*截止日期:2014-07-18 23:59:59 GMT
*主题名称:email.us-east-1.amazonaws.com匹配
*发卡机构:/C=US/O=VeriSign,Inc./OU=VeriSign Trust Network/OU=at的使用条款https://www.verisign.com/rpa (c) 10/CN=VeriSign 3级安全服务器CA-G3
*SSL证书验证正常。
POST/HTTP/1.1
用户代理:SimpleEmailService/php
接受:*/*
日期:2014年1月21日星期二19:25:04 UTC
主持人:email.us-east-1.amazonaws.com
X-Amzn-授权:
X-CK活动:2014年新年
评论:2014年新年
返回路径:2014年新年
内容类型:application/x-www-form-urlencoded
内容长度:45171
预期:100人继续
HTTP/1.1 100继续
HTTP/1.1200ok
x-amzn-RequestId:
内容类型:text/xml
内容长度:326
日期:2014年1月21日星期二19:25:04 GMT
*0到主机email.us-east-1.amazonaws.com的连接保持不变
*正在关闭连接#0
在电子邮件中,x标题已消失
返回路径标头替换为
Return-Path: <longstring>@amazonses.com
content-Type: multipart/alternative;
boundary="----=_Part_<numbers>"
Date: Tue, 21 Jan 2014 19:14:17 +0000
Message-ID: <sting.amazonses.com>
X-SES-Outgoing: <string>
X-OriginalArrivalTime: 21 Jan 2014 19:14:19.0370 (UTC) FILETIME=[FC02ECA0:01CF16DC]
------=_Part_<numbers>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
返回路径:@amazonses.com
内容类型:多部分/备选;
boundary=“---=\u零件”
日期:2014年1月21日星期二19:14:17+0000
消息ID:
X-SES-EXOUTING:
X-OriginalArrivalTime:2014年1月21日19:14:19.0370(UTC)文件时间=[FC02ECA0:01CF16DC]
------=\u部分_
内容类型:文本/纯文本;字符集=UTF-8
内容传输编码:7bit
注意:我已将一些内容替换为etc您正在设置
$header[]
,但传递$headers
-可能是打字错误?对不起,这是一个打字错误,不在我的代码中,amazon安全密钥也通过该数组传递,发送电子邮件需要此密钥,因此,如果该数组未正确传递,则电子邮件发送将失败。这就是让我困扰的地方,amazon密钥本身就是一个x-header,我正试图以同样的方式传递其他的。我确信它可以与curl一起工作,你只需要得到正确的标题。作为最后手段,您可以在使用SDK时嗅探请求,并在使用curl时进行比较。你链接到的文章建议必须提供内容长度,但我很确定curl在这个场景中默认添加了这一点。我不确定amazon或isp是否正在剥离标题,我已经在帖子中添加了curl的调试数据,在PHPs端一切似乎都正常。。。