type =“hidden”name =“currency_code”value =“‘。$ 货币 </跨度> ’。“&GT; &lt; input type =“hidden”name =“item_name”value =“‘。$ product_name。’”&gt; &lt; input type =“hidden”name =“amount”id =“p’。$ product_id。‘”value“to:”。$ receiver_email。’ 谢谢,享受! 〜谜 数字 </跨度> &lt; br /&gt; &lt; br
代码存在一些问题,您可以采取一些措施来开始调试过程。你不太可能在这里得到一个简单的解决方案,因为它是一个开放式的问题。
在做任何事之前,请确保 error_reporting 被设置为 E^ALL 和 display_errors 被设置为 On 在你的 php.ini 。 ( 如果你需要,可以使用Turorial )。检查你的 error_log - 如果存在 - 立即提供线索。
error_reporting
E^ALL
display_errors
On
php.ini
error_log
你需要申报 $message 在向其添加更多数据之前。您开始将数据附加到 $message 在第77行( $message .= $responder_to_use->message_body; )但它尚未设置,这将产生警告。
$message
$message .= $responder_to_use->message_body;
现在有三个原因导致电子邮件本身无法发送:
$txn_id_check
false
$txn_id
我们的地址是#1。在服务器上创建一个文件,其中包含1行,向您发送简单的电子邮件:
<?php mail('your@email', 'Test email', 'Yay, I can send mail!'); ?>
在浏览器中访问该文件。检查您的收件箱,并检查您的垃圾邮件。没有邮件?这就是问题所在。
下一步#2:这可能是脚本在用户甚至到达PayPal之前将事务添加到数据库的问题。我们没有这个代码,但是您可以轻松检查 - 只需检查数据库以查看是否存在任何行。
#3:语法错误应该很容易检查,只需直接在浏览器中访问IPN脚本即可。将显示致命错误。
还是行不通?其他地方可能存在问题。检查的最佳方法是进行一些基本的调试......
首先发送完整的 $_POST 通过电子邮件将数组放在脚本顶部。
$_POST
<?php mail('your@email', 'Full Post Data - '.time(), print_r($_REQUEST, true)); // STEP 1: Read POST data // reading posted data from directly from $_POST causes serialization // issues with array data in POST // reading raw POST data from input stream instead. $raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); [...]
并在最后通过电子邮件发送脚本的输出。
<?php ob_start(); $time = time(); // Referenced in your email subjects. It will get confusing with lots of these emails otherwise. Gmail and other clients who use a conversation view will properly catalogue these emails if the subjects match. mail('your@email', 'Full Post Data - '.$time, print_r($_REQUEST, true)); // STEP 1: Read POST data // reading posted data from directly from $_POST causes serialization // issues with array data in POST // reading raw POST data from input stream instead. [...] // Rest of your script here... $output_buffer = ob_get_contents(); ob_end_clean(); mail('your@email', 'Output buffer - '.$time, $output_buffer); ?>
$cleanedFrom = 'Ashutosh'; $to ='awesomeworks1@gmail.com; $subject = 'CONTACT US'; $headers = "From: " . $cleanedFrom . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message= '<html><body>'; $message .= '<table rules="all" style="border-color: #68A1D7;" cellpadding="15" width="450" align="center">'; $message .= "<tr style='background: #68A1D7; color: #fff;'><td colspan='2'><strong>CONTACT US</strong></td></tr>"; $message .= "<tr><td><strong>Name:</strong> </td><td>" .$ram[0]['name'] . "</td></tr>"; $message .= "<tr style='background:#68A1D7;'><td colspan='2'> </td></tr>"; $message .= "</table>"; $message .= "</body></html>"; $send = mail($to, $subject, $message, $headers); if($send) { echo "<script> alert('Message Sent. Thank you') </script>"; echo "<script>window.location='$webroot'</script>"; exit; } else { echo "<script> alert('Message Not Sent. Thank you') </script>"; echo "<script>window.location='$webroot'</script>"; exit; }
打开php.ini中的邮件。
你需要这样的东西:
在php.ini中:
[mail function] ; For Win32 only. ;SMTP = localhost ;smtp_port = 25 ; For Win32 only. ;sendmail_from = me@example.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = /usr/sbin/sendmail -t -i -f me@example.com
以“;”开头的行被注释掉了。因此,请确保根据您所使用的操作系统取消注释正确的部分。