Orionsbelter Posted December 10, 2011 Share Posted December 10, 2011 hi there i'm currently using paypals IPN to send details back to my script where it handles the info and send and instant email that will include details of how to download thier products. However the script is not sending the email with the details. And i don't get any errors, it does however send a test email each time so i do know the sendmail function works below is all supporting code: <?PHP $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); if (!$fp) { } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) {} else if (strcmp ($res, "INVALID") == 0) {} } fclose ($fp); } //------- if ($_POST['mc_currency'] == USD) $gross = $_POST['payment_gross']; else $gross = $_POST['mc_gross']; //---------------------------------- ?> <?PHP include 'include/mysql.php'; include 'include/global.php'; include 'library/sendmail.php'; $SQL = "SELECT * FROM `PRODUCTS` WHERE `TITLE` '$_POST[item_number]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result ); $hour = date("G:i"); $day = date("d"); $month = date("m"); $year = date("Y"); $get_id = $row[iD]; if (empty($get_id)) die(); //--------------------------------------- if ($_POST[payment_status] != Completed) { $sql = "UPDATE ORDERS SET PAYMENT_STATUS = '$_POST[payment_status]', REASON_CODE = '$_POST[reason_code]' WHERE TXN_ID = '$_POST[parent_txn_id]'"; $query = mysql_query($sql); } else { $sql = "INSERT INTO ORDERS SET PRODUCT = '$_POST[item_name]', ITEM_NUMBER = '$row[iD]', PAYER_EMAIL = '$_POST[payer_email]', DLC = '0', H = '$hour', D = '$day', M = '$month', Y = '$year', ADDRESS_COUNTRY = '$_POST[address_country]', GROSS = '$gross', PAYMENT_STATUS = '$_POST[payment_status]', PAYMENT_TYPE = '$_POST[payment_type]', PAYER_STATUS = '$_POST[payer_status]', STATUS = '$status', TXN_ID = '$_POST[txn_id]'"; $query = mysql_query($sql); } $SQL = "SELECT * from USERS WHERE EMAIL = '$_POST[payer_email]' AND STATUS != '1'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result ); if ($row[email] == $nil && $_POST[payer_email] != $nil) { $sql = "INSERT INTO USERS SET EMAIL = '$_POST[payer_email]', PASSWORD = '$_POST[txn_id]', ADDRESS_COUNTRY = '$_POST[address_country]', CITY = '$_POST[address_city]', FIRSTNAME = '$_POST[first_name]', LASTNAME = '$_POST[last_name]'"; $query = mysql_query($sql); } else { $sql = "UPDATE USERS SET PASSWORD = '$_POST[txn_id]' WHERE EMAIL = '$_POST[payer_email]' AND STATUS !='1'"; $query = mysql_query($sql); } $SQL = "SELECT * from PRODUCTS WHERE ID = '$get_id'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result ); if ($row[FILE_URL] != $nil) $dlinfo = "<BR><BR>Your download username is : ".$_POST[payer_email]."<BR>Your download password is : ".$_POST[txn_id]."<BR><BR>Visit http://f.cuescues.com/download.php to download"; $SQL = "SELECT * from EMAIL_TEMPLATES WHERE ID = '$row[email_TEMPLATES]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result ); $email_body = preg_replace("/\n/","\n<BR>",$row[bODY]); sendmail("$_POST[payer_email]", "HIDDEN","$row[sUBJECT]","$email_body$dlinfo<BR><BR>$rowxxx[sIGNATURE]"); sendmail("HIDDEN", "HIDDEN","$row[sUBJECT]","$email_body$dlinfo<BR><BR>$rowxxx[sIGNATURE]"); echo"$dlinfo"; ?> [code] sendmail.php [code] <?PHP sendmail('[email protected]','[email protected]','hi','hi'); function sendmail($to,$from,$subject,$body){ $from="[email protected]"; $to="$to"; $font1s.= "MIME-Version: 1.0\r\n"; $font1s.= "Content-type: text/html; "; $font1s.= "charset=iso-8859-1\r\n"; $font1s.= "From: $from"; $subject = "$subject"; $body = "<HTML><BODY> $body </BODY></HTML> "; mail($to,$subject,$body,$font1s); } ?> global.php <?php if(stristr($_SERVER['SERVER_SOFTWARE'],'microsoft')) error_reporting("E_ALL"); //---------------------------------------------------------------------------------- $script_title = ""; $version = "3.0"; @$SQLxxx = "SELECT * from SETTINGS"; $resultxxx = @mysql_query( $SQLxxx ); $rowxxx = @mysql_fetch_array( $resultxxx ); //---------------------------------------------------------------------------------- if ($rowxxx[AFFID] != '') $aff = "?xyz=$rowxxx[AFFID]"; $by = "Sell eBooks on Ebay"; if (empty($_GET ) || $_GET == home) $by = "Sell eBooks on Ebay"; //---------------------------------------------------------------------------------- if (empty($rowxxx[PHOTOSIZE])) $rowxxx[PHOTOSIZE] = 550; if (empty($rowxxx[THUMBSIZE])) $rowxxx[THUMBSIZE] = 115; //---------------------------------------------------------------------------------- if ($rowxxx[CURRENCY] == USD) {$cname = 'US Dollars'; $csymbol = '$';} if ($rowxxx[CURRENCY] == CAD) {$cname = 'Canadia Dollars'; $csymbol = '$';} if ($rowxxx[CURRENCY] == EUR) {$cname = 'Euros'; $csymbol = '€';} if ($rowxxx[CURRENCY] == GBP) {$cname = 'Pounds Sterling'; $csymbol = '£';} if ($rowxxx[CURRENCY] == JYN) {$cname = 'Yen'; $csymbol = '¥';} if ($rowxxx[CURRENCY] == AUD) {$cname = 'Australian'; $csymbol = '$';} //---------------------------------------------------------------------------------- ?> please help as this is soo stressing me out Quote Link to comment https://forums.phpfreaks.com/topic/252912-paypal-instant-email-send-not-working/ Share on other sites More sharing options...
Orionsbelter Posted December 11, 2011 Author Share Posted December 11, 2011 also th sendmail code <?PHP sendmail('tester','tester','test','test'); function sendmail($to,$from,$subject,$body){ $from="[email protected]"; $to="$to"; $font1s.= "MIME-Version: 1.0\r\n"; $font1s.= "Content-type: text/html; "; $font1s.= "charset=iso-8859-1\r\n"; $font1s.= "From: $from"; $subject = "$subject"; $body = "<HTML><BODY> $body </BODY></HTML> "; mail($to,$subject,$body,$font1s); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/252912-paypal-instant-email-send-not-working/#findComment-1296669 Share on other sites More sharing options...
dweeber Posted December 11, 2011 Share Posted December 11, 2011 You are not really showing where in your code you are calling the sendmail function. You did include at the top of your sendmail script: sendmail('tester','tester','test','test'); But that isn't going to do anything. Is that really in your code, or did you just change all the inputs to tester? You are also not testing for a result as to if it was accepted or not. So if the mail function is failing, your code would not know it. Quote Link to comment https://forums.phpfreaks.com/topic/252912-paypal-instant-email-send-not-working/#findComment-1296725 Share on other sites More sharing options...
Orionsbelter Posted December 11, 2011 Author Share Posted December 11, 2011 No that was just what i filled in to show you what code i was using to test the sendmail function. It worked soo i understand the mail function is not failing, could the body message text contain things that may make the function fail? Quote Link to comment https://forums.phpfreaks.com/topic/252912-paypal-instant-email-send-not-working/#findComment-1296924 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.