2013-03-29 128 views
-2

發生奇怪的錯誤我不知道如何解決。 這是錯誤:AWS SDK在嘗試使用SES發送電子郵件時引發錯誤

(!) Catchable fatal error: Argument 2 passed to Guzzle\Service\Client::getCommand() must be an array, string given, called in phar://C:/wamp/www/PHPCodeLance/WebTech/Projects/MIB v2/lib/aws/aws.phar/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php on line 93 and defined in phar://C:/wamp/www/PHPCodeLance/WebTech/Projects/MIB v2/lib/aws/aws.phar/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php on line 113 
Call Stack 
# Time Memory Function Location 
1 0.0009 676280 {main}() ..\test.php:0 
2 0.0557 3311632 Aws\Ses\SesClient->send_email() ..\test.php:30 
3 0.0557 3312128 Aws\Common\Client\AbstractClient->__call() ..\test.php:30 
4 0.0557 3312208 Guzzle\Service\Client->__call() ..(null):103 
5 0.0557 3312296 Guzzle\Service\Client->getCommand() ..(null):93 

這是我使用的代碼(直接從AWS頁)

$client = SesClient::factory(array(
    'key' => '', 
    'secret' => '', 
    'region' => 'us-east-1' 
)); 

$response = $client->send_email(
    '[email protected]', // Source (aka From) 
    array('ToAddresses' => array(// Destination (aka To) 
     '[email protected]' 
    )), 
    array(// Message (short form) 
     'Subject.Data' => 'Email Test ' . time(), 
     'Body.Text.Data' => 'This is a simple test message ' . time() 
    ) 
); 

// Success? 
var_dump($response->isOK()); 

更新!!!:修正了上述問題

,現在我得到了SSL證書問題:

Guzzle\Http\Exception\CurlException: [curl] 60: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed [url] https://email.us-east-1.amazonaws.com/ in phar://C:/wamp/www/PHPCodeLance/WebTech/Projects/MIB v2/lib/aws/aws.phar/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php on line 578 

在此先感謝

+4

如果您提到您如何解決第一個錯誤,以便下一個搜索它的人可以實際使用此頁而不是沒有任何信息,那將會更有幫助。 – JPR

回答

0

首先,你應該包含這段代碼來實例化客戶端並在try-catch塊中發送電子郵件,這肯定會解決可捕獲的致命錯誤部分並允許你的代碼繼續執行。

至於getCommand參數問題,我的猜測是你的參數send_email()有一些問題傳遞給調用堆棧。如果不通過SDK進行挖掘,我不知道我的頭頂是什麼參數專門傳遞給getCommand,但是您擁有所需的所有信息來調試問題,因爲您應該能夠映射如何通過參數傳遞通過堆棧跟蹤中顯示的每個調用,一路調試來驗證傳遞給每個函數的內容是什麼。

+0

雖然這段代碼在AWS SES文檔中,所以我認爲它應該可以工作。 –

+0

難道是我使用AWS的錯誤代碼片段嗎? 在這種情況下,有人可以鏈接到正確的文檔,AWS是有點混淆.. –

+0

你使用的是2.0行嗎? send_email()來自舊的1.0庫,該庫已被棄用。請參閱http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.Ses.SesClient.html – methai

0

SSL的問題是因爲CURL不再捆綁CA證書,您需要設置正確的CA信息。

解決方案1(修改了php.ini):從http://curl.haxx.se/docs/caextract.html

  • 放置在您的本地系統上

    1. 下載CA束(cacert.pem)(用於例如:C:\ XAMPP \ CACERT。 PEM)
    2. 打開你的php.ini
    3. 設置curl.ca_info選項指向cacert.pem的位置

      Example: curl.ca_info="C:\xampp\cacert.pem" 
      
    4. 重啓Apache

    解決方案2(每個CURL調用之前設置選項)

    1. 下載CA從http://curl.haxx.se/docs/caextract.html
    2. 放置在您的本地系統上(如用於束(cacert.pem) :C:\ XAMPP \ cacert.pem)
    3. 收件以下代碼:

      curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, TRUE); 
      curl_setopt ($ch, CURLOPT_CAINFO, "pathto\cacert.pem"); 
      

    來源:http://tumblr.wehavefaces.net/post/52114563111/environment-windows-xampp-curl-library

  • 相關問題