Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-14-2012, 02:45 PM   PM User | #16
leslie.jones
New Coder

 
Join Date: Nov 2011
Posts: 88
Thanks: 4
Thanked 26 Times in 26 Posts
leslie.jones is an unknown quantity at this point
Quote:
Originally Posted by TestingPHP View Post
Mailing does work on my VPS
PHP Code:
<?php
 $to      
'peanuthitz@hotmail.co.uk';
 
$subject 'DONATION NOTIFICATION - Someone has purchased your product!';
 
$message 'hello';
 
 
mail($to$subject$message);
 
?>
that works!

But it isn't working when i buy the ipn product it's not sending the email, please help me:/
The point you are missing - and it's an easy one that many other people miss - is what happens if your delivery fails. I assume you don't have access to the mail server logs(?) so you are relying on bounces working properly if something in the mail system fails. Do you get a bounce if you send to a totally invalid recipient like:

PHP Code:
<?php
 $to      
'blahrandomstringstuffbounce@hotmail.co.uk';
 
$subject 'DONATION NOTIFICATION - Someone has purchased your product!';
 
$message 'hello';
 
 
mail($to$subject$message);
 
?>
If you try this, do you get a bounce somewhere saying:
Quote:
<blahrandomstringstuffbounce@hotmail.co.uk>: host mx4.hotmail.com[65.54.188.72]
said: 550 Requested action not taken: mailbox unavailable (in reply to RCPT
TO command)
???
The reason it's important: If the mail fails, you need to know it has failed and why. Test this *first* - unless you have access to the raw mail server logs on your host / hosting account - in which case those will tell you what is happening. If you don't get the bounce, try this:

PHP Code:
<?php
 $to      
'blahrandomstringstuffbounce@hotmail.co.uk';
 
$subject 'DONATION NOTIFICATION - Someone has purchased your product!';
 
$message 'hello';

mail($to$subject$message"-fpostmaster@your.domain.name.co.uk");
 
?>
I've not looked at the rest of your code to ensure the IPN returns as it should etc - I assume you've already established that.
leslie.jones is offline   Reply With Quote
Old 06-14-2012, 03:15 PM   PM User | #17
TestingPHP
New Coder

 
Join Date: Jun 2012
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
TestingPHP is an unknown quantity at this point
Quote:
Originally Posted by leslie.jones View Post
The point you are missing - and it's an easy one that many other people miss - is what happens if your delivery fails. I assume you don't have access to the mail server logs(?) so you are relying on bounces working properly if something in the mail system fails. Do you get a bounce if you send to a totally invalid recipient like:

PHP Code:
<?php
 $to      
'blahrandomstringstuffbounce@hotmail.co.uk';
 
$subject 'DONATION NOTIFICATION - Someone has purchased your product!';
 
$message 'hello';
 
 
mail($to$subject$message);
 
?>
If you try this, do you get a bounce somewhere saying:


???
The reason it's important: If the mail fails, you need to know it has failed and why. Test this *first* - unless you have access to the raw mail server logs on your host / hosting account - in which case those will tell you what is happening. If you don't get the bounce, try this:

PHP Code:
<?php
 $to      
'blahrandomstringstuffbounce@hotmail.co.uk';
 
$subject 'DONATION NOTIFICATION - Someone has purchased your product!';
 
$message 'hello';

mail($to$subject$message"-fpostmaster@your.domain.name.co.uk");
 
?>
I've not looked at the rest of your code to ensure the IPN returns as it should etc - I assume you've already established that.
You don't understand, it always sends the email, it's just when i'm using it on the IPN, I think I added the code to the wrong place, here's the whole source!

Please fix it!

Click here to download the IPN source!
TestingPHP is offline   Reply With Quote
Old 06-14-2012, 03:39 PM   PM User | #18
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Okay, we have to go back a few steps here to the beginning.
Does this block process upon payment?
PHP Code:
      if ($p->validate_ipn()) {
         
         
// Payment has been recieved and IPN is verified.  This is where you
         // update your database to activate or process the order, or setup
         // the database with the user's order details, email an administrator,
         // etc.  You can access a slew of information via the ipn_data() array.
 
         // Check the paypal documentation for specifics on what information
         // is available in the IPN POST variables.  Basically, all the POST vars
         // which paypal sends, which we send back for validation, are now stored
         // in the ipn_data() array.
         
$fh fopen(".ipn""a");
         
fwrite($fhprint_r($p->ipn_datatrue));
         
fclose($fh);
 
         
// For this example, we'll just email ourselves ALL the data.
         
if($p->ipn_data["payment_status"] != "Completed") die();
 
         if(
$p->ipn_data["mc_gross"] > && strcmp ($p->ipn_data["business"],$EMAIL) == 0) {
             
$user $p->ipn_data["custom"];
             
$date $p->ipn_data["payment_date"];
             
$prodid $p->ipn_data["item_number"];
             
$amount $p->ipn_data["mc_gross"];
             
$amountTickets 1;
   
             
$user str_replace("-""_"$user);
             
$user str_replace(" ""_"$user);
             
$user mysql_real_escape_string($user);
             
mysql_query("INSERT INTO donation (username, time, productid, price, tickets) VALUES ('" $user "', '" $date "', '" $prodid "', " $amount ", " $amountTickets ");");
             
$fh fopen(".ipnerr""a");
             
fwrite($fhmysql_error());
             
fclose($fh);
         }
      } 
?
This is your return notify command (at least I'm pretty sure, its been awhile since I've used paypal with a script, but the notify_url should be where it contacts back). It comes back to the paypal.php providing an action of ipn. It should write to a file as well as insert into a database, but there is no indication here that it sends an email, so check first if its been inserted into the db and written to file.
Fou-Lu is offline   Reply With Quote
Old 06-14-2012, 04:10 PM   PM User | #19
leslie.jones
New Coder

 
Join Date: Nov 2011
Posts: 88
Thanks: 4
Thanked 26 Times in 26 Posts
leslie.jones is an unknown quantity at this point
Quote:
Originally Posted by TestingPHP View Post
You don't understand, it always sends the email, it's just when i'm using it on the IPN, I think I added the code to the wrong place, here's the whole source!

Please fix it!
OK, I'm out - that was way to rude.

If you want someone else to do it for you, try here: https://www.elance.com

Good luck
leslie.jones is offline   Reply With Quote
Old 06-14-2012, 06:01 PM   PM User | #20
TestingPHP
New Coder

 
Join Date: Jun 2012
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
TestingPHP is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
Okay, we have to go back a few steps here to the beginning.
Does this block process upon payment?
PHP Code:
      if ($p->validate_ipn()) {
         
         
// Payment has been recieved and IPN is verified.  This is where you
         // update your database to activate or process the order, or setup
         // the database with the user's order details, email an administrator,
         // etc.  You can access a slew of information via the ipn_data() array.
 
         // Check the paypal documentation for specifics on what information
         // is available in the IPN POST variables.  Basically, all the POST vars
         // which paypal sends, which we send back for validation, are now stored
         // in the ipn_data() array.
         
$fh fopen(".ipn""a");
         
fwrite($fhprint_r($p->ipn_datatrue));
         
fclose($fh);
 
         
// For this example, we'll just email ourselves ALL the data.
         
if($p->ipn_data["payment_status"] != "Completed") die();
 
         if(
$p->ipn_data["mc_gross"] > && strcmp ($p->ipn_data["business"],$EMAIL) == 0) {
             
$user $p->ipn_data["custom"];
             
$date $p->ipn_data["payment_date"];
             
$prodid $p->ipn_data["item_number"];
             
$amount $p->ipn_data["mc_gross"];
             
$amountTickets 1;
   
             
$user str_replace("-""_"$user);
             
$user str_replace(" ""_"$user);
             
$user mysql_real_escape_string($user);
             
mysql_query("INSERT INTO donation (username, time, productid, price, tickets) VALUES ('" $user "', '" $date "', '" $prodid "', " $amount ", " $amountTickets ");");
             
$fh fopen(".ipnerr""a");
             
fwrite($fhmysql_error());
             
fclose($fh);
         }
      } 
?
This is your return notify command (at least I'm pretty sure, its been awhile since I've used paypal with a script, but the notify_url should be where it contacts back). It comes back to the paypal.php providing an action of ipn. It should write to a file as well as insert into a database, but there is no indication here that it sends an email, so check first if its been inserted into the db and written to file.
I don't know how it works, but after you pay go goes back to my site & says payment has been successful etc.

I just don't know where to place the emailing script.

And there was a database also, but I didn't know where to remove it.
TestingPHP is offline   Reply With Quote
Old 06-14-2012, 06:02 PM   PM User | #21
TestingPHP
New Coder

 
Join Date: Jun 2012
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
TestingPHP is an unknown quantity at this point
Quote:
Originally Posted by leslie.jones View Post
OK, I'm out - that was way to rude.

If you want someone else to do it for you, try here: https://www.elance.com

Good luck
My intention was not to be rude, if you found that offensive then, I'm sorry...?
TestingPHP is offline   Reply With Quote
Old 06-15-2012, 11:30 AM   PM User | #22
TestingPHP
New Coder

 
Join Date: Jun 2012
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
TestingPHP is an unknown quantity at this point
still need help
TestingPHP is offline   Reply With Quote
Old 06-15-2012, 03:16 PM   PM User | #23
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by TestingPHP View Post
I don't know how it works, but after you pay go goes back to my site & says payment has been successful etc.

I just don't know where to place the emailing script.

And there was a database also, but I didn't know where to remove it.
From the code blocks you have posted, which of the success messages are shown?

And as iball has mentioned, make sure you use the sandbox. The developer zone of paypal will show you how to make accounts for it, and all that changes is the link you send payments to.
Fou-Lu is offline   Reply With Quote
Old 06-16-2012, 12:47 PM   PM User | #24
TestingPHP
New Coder

 
Join Date: Jun 2012
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
TestingPHP is an unknown quantity at this point
Bump, still looking for a spoon feeder O_O
TestingPHP is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:42 PM.


Advertisement
Log in to turn off these ads.