Where is the path for the link in password change emails?
Moderators: Developer, Contributor
Where is the path for the link in password change emails?
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,
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,
The URL is generated programmatically, around line 71 in the config_defaults_inc.php:
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
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/';
}
See this:
http://www.cpqlinux.com/hostname.html
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.
http://localhost/mantis/verify.php?id=3 ... 0ee5ab527a
^^^^^^
The "localhost" bit is the problem.
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:
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).
Code: Select all
<?php
echo phpinfo();
?>
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>
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).
Last edited by gravyface on 17 Aug 2006, 18:33, edited 1 time in total.