I have a page on a website that grabs a visitor's IP address and emails to an email account. My goal is to use a tool, GeoIP lookup, to associate the IP address with a city in the email content. What I want is to add the following command to the email content: geoiplookup $remoteIpAddress, but my attempts aren't working. I'm hoping somebody familiar with PHP can point me in the right direction. Here is the code that is currently working:
<?php
include('session.php');
$yourEmailAddress = "[email protected]";
$emailSubject = "Example Subject";
$remoteIpAddress = $_SERVER['REMOTE_ADDR'];
$emailContent = "Blah Blah Blah: ".$remoteIpAddress;
mail($yourEmailAddress, $emailSubject, $emailContent);
I tried setting the variable with $city = exec("geoiplookup $remoteIpAddress"); and updating $emailContent to: $emailContent = "Blah Blah Blah: ".$remoteIpAddress .$city; but that didn't work. I tried a few other variations of that, trying to get it working with shell_exec, with and without quotations, and nothing has worked. Hoping somebody can point me in the right direction. Thanks!
https://ipstack.com/(free with limitations) in order to achieve your goalmail()function or string concatenation?