Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Trouble with PHP mail function

  • 23-04-2014 05:10PM
    #1
    Registered Users, Registered Users 2 Posts: 867 ✭✭✭


    Im trying to write up a paypal ipn script and have managed to get it working and inserting transactions into the database etc but I seem to be having a simple mail problem where I would like to send the payer an email after completing transaction but I just cant figure out whats wrong.
    $txn_id = $_POST['txn_id'];
    $payer_email = $_POST['payer_email'];
    $custom = $_POST['custom'];
    
    
    
    $sql = mysql_query("INSERT INTO transactions (product_id_array, payer_email, first_name, last_name, payment_date, mc_gross, payment_currency, txn_id, receiver_email, payment_type, payment_status, txn_type, payer_status, address_street, address_city, address_state, address_zip, address_country, address_status, notify_version, verify_sign, payer_id, mc_currency, mc_fee) 
       VALUES('$custom','$payer_email','$first_name','$last_name','$payment_date','$mc_gross','$payment_currency','$txn_id','$receiver_email','$payment_type','$payment_status','$txn_type','$payer_status','$address_street','$address_city','$address_state','$address_zip','$address_country','$address_status','$notify_version','$verify_sign','$payer_id','$mc_currency','$mc_fee')") or die ("unable to execute the query");
    
    mail([COLOR="Navy"]$payer_email[/COLOR], "for you!", "content goes here", "From: xxx@xxx.ie");
    
    mail("xxxx@xxxxx.ie", "good IPN RESULT OK", $req, "From: xxx@xxxx.ie");
    

    Think something is wrong with the blue part above, the second ipn result ok mail gets sent perfectly to my inbox every time i test script on paypal just not the first.

    cheers for any help


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    If the second mail function works and the first one does not, then your problem is almost certainly not with the mail function, given that the only real difference between the two is the use of a hardcoded or variable email address.

    Instead, it is most likely a problem with $payer_email. For example, you say you have it inserting transactions into the database; what values is it recording for the payer_email field? What happens if you try to echo $payer_email or $_POST?

    Were I to guess, your problem is that $_POST is currently empty, because you have a typo in the form that sends it and so you don't actually name it payer_email.

    As an addendum, your script is wide open to a SQL injection exploit. And by "wide open", I mean pants down, bent over, cheeks apart at a Bacchanalia and a welcome mat just behind you.


Advertisement