Took a look at the module in special-mail-tags.php
There $_SERVER['REMOTE_ADDR']
is used. This can cause the described issue, it returns an internal proxy-ip of the provider (actually not my webserver) in my case. See e.g. here.
Possible replacement for current [_remote_ip]
handling:
if ( '_remote_ip' == $name ) {
$_ip_addr = $_SERVER['REMOTE_ADDR'];
if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $_SERVER ) )
$_ip_addr = array_pop( explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
$output = preg_replace( '/[^0-9a-f.:, ]/', '', $_ip_addr );
}
Added also another field [_remote_host]
which returns the hostname, if possible, otherwise the ip:
elseif ( '_remote_host' == $name ) {
$_ip_addr = $_SERVER['REMOTE_ADDR'];
if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $_SERVER ) )
$_ip_addr = array_pop( explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
$output = @gethostbyaddr( $_ip_addr );
}
Example mail-tags: IP: [_remote_host] ([_remote_ip])
Example result: IP: some.provider.domain.net (xx.xxx.xxx.xx)
Feel free to use the code. Thanks for your great plugin!