Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Trouble with PHP mail function

  • 23-04-2014 5:10pm
    #1
    Registered Users 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