Page 1 of 2
Where is the path for the link in password change emails?
Posted: 17 Aug 2006, 12:04
by btenpenny
When my Mantis system sends emails for changing passwords, the clickable link has "localhost" in the rather than the ip/hostname of the machine it is running on. Obviously, this doesn't work unless you happen to be reading the email on the machine itself.
I'm sure I've missed changing a default somewhere, but I can't determine where it derives that particular link from.
Any helpers?
Thanks,
Posted: 17 Aug 2006, 12:56
by gravyface
The URL is generated programmatically, around line 71 in the config_defaults_inc.php:
Code: Select all
if ( isset( $_SERVER['HTTP_HOST'] ) ) {
$t_host = $_SERVER['HTTP_HOST'];
} else if ( isset( $_SERVER['SERVER_NAME'] ) ) {
$t_host = $_SERVER['SERVER_NAME'] . $t_port;
} else if ( isset( $_SERVER['SERVER_ADDR'] ) ) {
$t_host = $_SERVER['SERVER_ADDR'] . $t_port;
} else {
$t_host = 'www.example.com';
}
$t_path = dirname( strip_tags( $_SERVER['PHP_SELF'] ) );
if ( '/' == $t_path || '\\' == $t_path ) {
$t_path = '';
}
$g_path = $t_protocol . '://' . $t_host . $t_path.'/';
} else {
$g_path = 'http://www.example.com/mantis/';
}
These are standard PHP/Apache/system environmental variables; check /etc/hostsname and /etc/network/interfaces (I think this is the same across distros; might be different in RedHat).
See this:
http://www.cpqlinux.com/hostname.html
Posted: 17 Aug 2006, 14:39
by btenpenny
Thanks for the info!
I saw that section of the code, but I can't figure out where it's pulling the info from.
This is on a Windows box. Does anyone know what the Windows version of this informatino would be?
Posted: 17 Aug 2006, 14:44
by gravyface
Are you running Apache or IIS?
Posted: 17 Aug 2006, 14:49
by btenpenny
Apache
Posted: 17 Aug 2006, 15:18
by shark
$g_smtp_host in the config file.
go to the "# Mantis Email Settings" section of the config_defaults_inc.php file and go through those settings and set what you need for email in your config_inc.php file.
Posted: 17 Aug 2006, 15:23
by btenpenny
Isn't $g_smtp_host the smtp server host name? My emails are going out, and arriving. It's just that the link they include looks something like this:
http://localhost/mantis/verify.php?id=3 ... 0ee5ab527a
^^^^^^
The "localhost" bit is the problem.
Posted: 17 Aug 2006, 15:29
by shark
lol, ok I misunderstood.
Let me find that setting... just a second.
Posted: 17 Aug 2006, 15:30
by shark
Check the "serverName" setting in httpd.conf for apache.
that might do it.
Posted: 17 Aug 2006, 15:34
by btenpenny
Already tried that one, it's configured with the IP of the machine.
Thanks for the idea, though!
Posted: 17 Aug 2006, 16:01
by shark
Digging through the code, gravyface is right on the money.
It appears that one of these:
$_SERVER['HTTP_HOST']
$_SERVER['SERVER_NAME']
$_SERVER['SERVER_ADDR']
needs to be set, to correctly create the url.
Check what those PHP vars are set to by running phpinfo.php
Posted: 17 Aug 2006, 17:55
by gravyface
Posted: 17 Aug 2006, 18:01
by btenpenny
Shark:
Yep, that looks like the culprit. Where are those values set? I can't find an entry for them.
Gravy: I've already got that set to the machine's IP
Thanks to both!
Posted: 17 Aug 2006, 18:24
by gravyface
PHP's environmental variables (also known as "CGI Variables") are pulled from the Web server. To see the values for yourself, create a php file with:
...and run it.
According to the Apache 2.x documentation, the ServerName defines your hostname. I'm wondering if perhaps since it's set to IP, it resolves to localhost (using local DNS cache or c:\windows\system32\etc\hosts).
I use virtual hosts (and I think Apache2 by default uses this) and under each virtual host, I have
ServerName appname.hostname like:
Code: Select all
<VirtualHost *>
ServerAdmin gravyface@foo.com
ServerName mantis.foo.com
ServerAlias mantis.foo.com
DocumentRoot /var/www/mantis
ErrorLog /var/log/apache2/mantis.error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/mantis.access.log combined
ServerSignature On
</VirtualHost>
This way, foo.com always resolves to my machine, and the "mantis" string sent in the header tells Apache which virtual host to use. I do not have my IP address anywhere in the Apache configuration; I have * for NameVirtualHost in the "default" file in /sites-available.
http://httpd.apache.org/docs/2.0/vhosts/examples.html
Try setting ServerName to your hostname and restarting; it can't hurt anything (unless it's in production of course).
Posted: 17 Aug 2006, 18:32
by btenpenny
Once again, thanks for all the suggestions!
I've been using phpinfo() to check these variables
To test, I changed ServerName to the hostname of the PC and restarted Apache. It still listed localhost in the variable field.