2013-09-25 2 views
0

IPN을 보내면 성공적으로 전송되었다고 말합니다. 그러나, 나는 결코 나의 전자 우편에 전자 우편을받지 않는다. 내 코드가 전송되지 않게하려면 무엇이 잘못 되었습니까? 또한 대중에게 개방 될 준비가되면 ToEmail을 [email protected]에서 내 항목을 구입 한 개인의 이메일로 어떻게 변경합니까? PHP에 익숙하지 않은데, IPN을 시도한 것은 이번이 처음이지만, 웹 사이트를 통해 비영리 비즈니스를 돕고 있으며이 문제를 해결하는 데 어려움을 겪고 있습니다. 어떤 도움이라도 대단히 감사하겠습니다. 미리 감사드립니다. 와 연결 : 항목PayPal IPN 전자 메일이 작동하지 않습니다.

<?php 
//Build the data to post back to Paypal 
$postback = 'cmd=_notify-validate'; 

// go through each of the posted vars and add them to the postback variable 
foreach ($_POST as $key => $value) { 
$value = urlencode(stripslashes($value)); 
$postback .= "&$key=$value"; 
} 

// build the header string to post back to PayPal system to validate 
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; 
$header .= "Content-Type: application/x-www-form-urlencoded\r\n"; 
$header .= "Content-Length: " . strlen($postback) . "\r\n\r\n"; 

// Send to paypal or the sandbox depending on whether you're live or developing 
//comment out one of the following lines 
//$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);//open the connection 
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); 
// or use port 443 for an SSL connection 
//$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); 

if (!$fp) 
{ 
    // HTTP ERROR Failed to connect 
    //error handling 
} 
else // if we've connected OK 
{ 
    fputs ($fp, $header . $postback);//post the data back 
    while (!feof($fp)) 
    { 
     $response = fgets ($fp, 1024); 

     if (strcmp ($response, "VERIFIED") == 0) //It's verified 
     { 
$ToEmail = '[email protected]'; 
$EmailSubject = 'Subject Here'; 
$mailheader = "From: ".$_POST['receiver_email']."\r\n"; 
$mailheader .= "Reply-To: ".$_POST['receiver_email']."\r\n"; 
$MESSAGE_BODY = "Name: ".$_POST['first_name'].""; 
$MESSAGE_BODY .= " 
I will write my message here."; 
$MESSAGE_BODY .= " 
Thank you, 
MY COMPANY NAME"; 
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader); 
     } 
     else if (strcmp ($response, "INVALID") == 0) 
     { 
      //the Paypal response is INVALID, not VERIFIED 
      // This implies something is wrong 
     } 
    } //end of while 
    fclose ($fp); 
} 
?> 

답변

0

당신은/1.0 HTTP를/1.1 HTTP에서 스크립트를 업데이트하고 두 호스트를 추가해야합니다.

$header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; 
$header .= "Content-Type: application/x-www-form-urlencoded\r\n"; 
$header .= "Content-Length: " . strlen($postback) . "\r\n\r\n"; 

이어야한다

$header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; 
$header .= "Content-Type: application/x-www-form-urlencoded\r\n"; 
$header .= "Host: www.paypal.com\r\n"; 
$header .= "Connection: close\r\n"; 
$header .= "Content-Length: " . strlen($postback) . "\r\n\r\n"; 
관련 문제