2011-12-19 2 views
0

전자 메일을 보내려면 Postmark를 사용하고 있습니다. 하지만 소인은 반송 된 이메일을 처리 할 수있는 URL을 설정할 수 있습니다. 이것을 사용하고 싶지만 데이터를 얻고 처리하는 방법을 모르겠습니다.Parse Postmark 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 참조) 분명히 _POST에 의존 다음은 간단한 코드의

을 할 수없는 소인표에서 몇 가지 매개 변수를 가져 와서 이메일을 생성합니다. 매개 변수를 가져 와서 당연히 필요한 다른 작업을 수행 할 수 있습니다.

<?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); 
} 
?>