hsraffety Posted October 7, 2008 Share Posted October 7, 2008 I would like to automatically send an e-mail whenever someone from a certain host visits my site. I know the IPs I'd like to use. Pretty much it'd be like this: User Opens Site E-mail Gets Sent in the Background IF the IP matches E-mail gets sent saying "Thanks for stopping by" That's it. Link to comment https://www.neowin.net/forum/topic/678740-quick-php-question/ Share on other sites More sharing options...
0 Sophism Posted October 7, 2008 Share Posted October 7, 2008 Uhh not possible... you need an email address to email.. you cannot email an Ip address. Link to comment https://www.neowin.net/forum/topic/678740-quick-php-question/#findComment-589924888 Share on other sites More sharing options...
0 d3nuo Posted October 7, 2008 Share Posted October 7, 2008 i assume there's some ip to email correlation that you have, right? there are a handful of ways i could think of to do this.. the way i would do it is get the IP of the IP address and then if the list isn't very long you can just so something like a case: $user_ip = $_SERVER['REMOTE_ADDR']; $email_addr = ""; switch($user_ip) { case "192.168.0.101": $email_addr = "[email protected]"; break; case "192.168.0.102": $email_addr = "[email protected]"; break; } if(strlen($email_addr)>0) { $subject = "Thank You!"; $body = "We just wanted to thank you for stopping by!"; @mail($email_addr, $subject, $body); } something like that should work ok. if the list is larger, i'd look into a more complex implementation involving using a mysql table to map IP's to email addresses (and use a query like "select email_addr from TABLENAME where user_ip = 'VALUE FROM PHP'S $user_ip VARIABLE'") let me know if you need me to explain anymore.. i didnt text the code but it was done up quick! to reiterate the first line of my response, you have to have an email address that you somehow can associate to an IP, otherwise there's no way to just use an email address Link to comment https://www.neowin.net/forum/topic/678740-quick-php-question/#findComment-589924896 Share on other sites More sharing options...
0 hsraffety Posted October 7, 2008 Author Share Posted October 7, 2008 I have both the e-mail and IP address. Thanks!!!! Link to comment https://www.neowin.net/forum/topic/678740-quick-php-question/#findComment-589925328 Share on other sites More sharing options...
Question
hsraffety
I would like to automatically send an e-mail whenever someone from a certain host visits my site.
I know the IPs I'd like to use. Pretty much it'd be like this:
User Opens Site
E-mail Gets Sent in the Background IF the IP matches
E-mail gets sent saying "Thanks for stopping by"
That's it.
Link to comment
https://www.neowin.net/forum/topic/678740-quick-php-question/Share on other sites
3 answers to this question
Recommended Posts