I would like to automatically switch this to “Offsite address” and populate it when a mail user is created (specifically with the email address that has just been created):
I am planning to use a stripped-down version of the webmin-virtualmin-password-recovery page that only offers to send the link, so user’s would see only that option:
My thinking is that most of the users who do not remember their passwords still have access to their mail, they’ve just put it into a mail client or stored it in their browser ages ago and don’t remember it now (and any that do wish to change that to some other address would of course be welcome to do so).
My thought was that something under System Settings -> Virtualmin Configuration -> Actions upon server and user creation might have this, much the way Virtualmin can issue commands after creating a server, something that allowed me to write a file to:
would do the trick, it appears that writing a file called “recovery” there with just an email address in it does what I want, but there seems to be no such option under “Actions upon server and user creation”.
What is the:
Notify other modules when updating mailbox Unix users
I can do this by editing the /usr/share/webmin/virtual-server/create-user.pl file but the GUI doesn’t use that (and editing webmin files directly seems like a bad choice), this:
# Set recovery email to the user's email if not already set
if (!defined($recovery)) {
$recovery = $user->{'email'};
}
Shimmed in right here:
# Create the user and virtusers and alias
&create_user($user, $d);
if ($pubkey) {
my $err = &add_domain_user_ssh_pubkey($d, $user, $pubkey);
&usage($err) if ($err);
}
# Set recovery email to the user's email if not already set
if (!defined($recovery)) {
$recovery = $user->{'email'};
}
# Create an empty mail file, if needed
if ($user->{'email'} && !$user->{'nomailfile'}) {
&create_mail_file($user, $d);
}
Does the trick as it assumes the address being made is the “–recovery” address if none it set.
All this is out of scope for admins using webmin/virtualmin as designed maybe it would be a better idea to add your questions to the relevant github issues rather than adding them to the forum areas as you may get some bad advice
This definitely seems beyond the scope of what I should be doing and I am not advising others to do it or implying a warranty, etc… but for the record (and in case I, or anyone else) come looking for this one day, I was able to shim such a function into /usr/share/webmin/virtual-server/save_user.cgi (at about line 598, indentation preserved for easy pasting) thusly:
# Check if the recovery address has been set by the user
if (!$user->{'recovery'} || $user->{'recovery'} eq '') {
# Write the email address to the constructed path file
open(my $rfh, '>>', "$user->{'home'}/.usermin/changepass/recovery") or die "Could not open file '$user->{'home'}/.usermin/changepass/recovery' $!";
print $rfh "$user->{'email'}\n"; # Write the email address to the constructed path
close($rfh);
}
(First it checks that the web-interface user hasn’t already set a recovery email address, and if not it uses the one it’s creating.)
For continuity it goes right here:
# Create the user and virtusers and alias
&create_user($user, $d);
# Check if the recovery address has been set by the user
if (!$user->{'recovery'} || $user->{'recovery'} eq '') {
# Write the email address to the constructed path file
open(my $rfh, '>>', "$user->{'home'}/.usermin/changepass/recovery") or die "Could not open file '$user->{'home'}/.usermin/changepass/recovery' $!";
print $rfh "$user->{'email'}\n"; # Write the email address to the constructed path
close($rfh);
}
# Send an email upon creation
if ($user->{'email'} || $newmailto) {
$emailmailbox = 1;
}