使用PHP curl在Amazon SES上使用x-header或自定义电子邮件标头

时间:2014-01-20 21:22:08

标签: php curl amazon-ses email-headers

我正在尝试使用curl获取自定义电子邮件标头(x-header),而不使用Amazon SDK。

$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);

标题不断被删除

是仅支持亚马逊SDK的自定义标头吗? 这篇文章似乎表明了这一点: http://www.techfounder.net/2011/03/23/mis-adventures-with-amazon-simple-email-services-ses/

使用

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.
&gt; 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

&lt; HTTP/1.1 100 Continue
&lt; HTTP/1.1 200 OK
&lt; x-amzn-RequestId: <string>
&lt; Content-Type: text/xml
&lt; Content-Length: 326
&lt; Date: Tue, 21 Jan 2014 19:25:04 GMT
* Connection #0 to host email.us-east-1.amazonaws.com left intact
* Closing connection #0

在电子邮件中,x-header消失了

返回路径标头由

替换
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

注意:我已用etc

替换了一些内容

0 个答案:

没有答案