2011-12-19 39 views
0

我正在使用郵戳發送電子郵件。 但郵戳允許您設置一個URL來處理退回的電子郵件。 我想用這個,但不知道如何獲取和處理數據。PHP中的解析郵戳反彈鉤

我的API的工作原理,但我不知道如何檢索數據郵戳發送到我的API。

<?php 

class BackendBillingAPI 
{ 
    public static function postmarkBounceHook() 
    { 
     $log = new SpoonLog('custom', PATH_WWW . '/backend/cache/logs/billing'); 

     // logging when we are in debugmode 
     if(SPOON_DEBUG) $log->write('Billing post (' . serialize($_POST) . ') triggered.'); 
     if(SPOON_DEBUG) $log->write('Billing get (' . serialize($_GET) . ') triggered.'); 
     if(SPOON_DEBUG) $log->write('Billing _REQUEST (' . serialize($_REQUEST) . ') triggered.'); 

    } 
} 

任何想法/想法?

回答

1

你需要解析POST裏面的JSON數據,你可以不依賴於彥博顯然是(因爲這不是一個多形式,看到this更多信息)

這裏有一個簡單的代碼,從郵戳反彈中獲取一些參數並生成電子郵件。您可以抓取參數並做任何您當然需要的東西

<?php 
$form_data = json_decode(file_get_contents("php://input")); 

// If your form data has an 'Email Address' field, here's how you extract it:  
$email_address = $form_data->Email; 
$details = $form_data->Details; 
$type = $form_data->Type; 

// Assemble the body of the email...            
$message_body = <<<EOM 
Bounced Email Address: $email_address 
Details: $details 
Type: $type 
EOM; 
if ($email_address) { 
    mail('ENTER YOUR EMAIL ADDRESS', 
     'Email bounced!', 
     $message_body); 
} 
?>