2014-02-27 52 views
0

我上设置通过我的PayPal IPN脚本自动发送的电子邮件的响应,但是工作下面的代码将导致PayPal的沙盒失败。PHP邮件功能造成的错误

// PAYMENT VALIDATED & VERIFIED! 

$email = $_POST['payer_email']; 
$password = mt_rand(1000, 9999); 

$to  = $email; 
$subject = 'Download Area | Login Credentials'; 
$message = ' 

Thank you for your purchase 

Your account information 
------------------------- 
Email: '.$email.' 
Password: '.$password.' 
------------------------- 

You can now login at http://yourdomain.com/PayPal/'; 
$headers = 'From:[email protected]<script type="text/javascript"> 
/* <![CDATA[ */ 
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})(); 
/* ]]> */ 
</script>' . "\r\n"; 

mail($to, $subject, $message, $headers);  

是否存在某种简单错误或脚本导致错误的更深层原因。请记住,我是新手,这是我从http://code.tutsplus.com/tutorials/using-paypals-instant-payment-notification-with-php--net-3271复制并粘贴的代码。

此外,没有从该电子邮件我使用必须位于我使用主办的脚本在同一台服务器上?

删除邮件以避免泄露个人信息。

+0

什么错误? –

+0

请不要在邮件中以明文形式发送任何密码。 –

+0

作为参考,IPN沙盒不会告诉我错误是什么,我只知道它不起作用。 –

回答

2

这是什么?

$headers = 'From:[email protected]<script type="text/javascript"> 
/* <![CDATA[ */ 
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})(); 
/* ]]> */ 
</script>' . "\r\n"; 

您的邮件标题中不能包含HTML或JavaScript。把那些可能导致你的错误的广告拿出来。

$headers = 'From:[email protected]'; 
+0

很想知道那里有什么 – 2014-02-27 02:18:14

+0

正如我在我的帖子中所说的,我只是从教程网站上拿了代码。我对PHP不太好。另外,我无意使用密码,我只是在那里,因为我从来没有摆脱它。我会试试你说的约翰。 –

+0

更新:上述解决方案允许IPN成功发送,但作为OP中的状态,我是否需要将FROM:Email需要托管在同一台服务器上? –