<?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';
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';
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!
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($fh, print_r($p->ipn_data, true));
fclose($fh);
// For this example, we'll just email ourselves ALL the data.
if($p->ipn_data["payment_status"] != "Completed") die();
?
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.
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!
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($fh, print_r($p->ipn_data, true));
fclose($fh);
// For this example, we'll just email ourselves ALL the data.
if($p->ipn_data["payment_status"] != "Completed") die();
?
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.
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.