I'm using a PHP mailsender and sending a link to a number of receivers. When they click on the link they will redirect to a PHP file that get their ip and then a header on that PHP file that redirect to a webpage.
This is my Question: Which ip is for which email (or reciever) ??
<a href="http://www.example.com/data.php" style="(css part)" >blahblah</a>
$data = ' ip --> '.$_SERVER['REMOTE_ADDR']."\n" ;
$ret = file_put_contents('data.txt', $data, FILE_APPEND | LOCK_EX);
If I understand your question correctly, what you are actually trying to accomplish is to figure out which person has opened your email, and you are collecting the IP address as a proxy, and then hope to figure out who it was based on the IP address.
Unfortunately, that is not going to work. Many (most) companies use NAT based firewalls, and thousands of users could all be accessing the Internet through the same IP address. And conversely, the same user can have a different IP address in the morning when he stops at Starbucks, in the afternoon at his desk at work, and after he gets home.
If you add IPv6 to the mix, things get even more complicated.
To solve your problem, you need to take a different approach. One easy solution is to assign each recipient a random, but unique, code. A 32-character string of hexadecimal digits would be good.
When you send the email, you store this code and the email address it belongs to. The link in your email would look like this:
<a href="http://www.example.com/data.php?code=11921af91234a8813fa" style="(css part)" >blahblah</a>
Note that this means that the URL will be different for each email you are sending.
On the receiving end, your data.php would then extract the code from the URL and save it to your database.
All that said: you will likely not be very happy with such a homegrown solution. You can buy software that does it off the shelf (or as a service), with very elaborate reporting capabilities.
Your biggest challenge will likely be spam filters and privacy filters - both can look for exactly that kind of code in a URL. With a commercial off-the-shelf solution, you leave this type of issue to the experts.