it's really strange, I have set my server listen on port 801, then I sent ecard to myself, and it came with double port number...then I uncoment that code in constants.php and got email with correct url/port .
but, anyway, I found out why it does doble port, because 4images checking only port 80 (default) and 443 (SSL). then it checking if $HTTP_SERVER_VARS['HTTP_HOST'] has the server URL...if it does, then it uses it, if not, then uses: getenv("SERVER_NAME"), then it add port (if it found from first step). but, here is why it shows double port:
$HTTP_SERVER_VARS['HTTP_HOST'] - includes port number, but getenv("SERVER_NAME") - doesnt...
so, here is the fix for u:
open global.php
Find: $script_url .= $port ;
replace with: $script_url .= (empty($HTTP_SERVER_VARS['HTTP_HOST'])) ? $port : "";
that should work. if it still doesnt work, then just comment that line.