Customize registration email

I have modified the email template files for new user creation [1] and resetting the password [2].
[1] /home/frappe/frappe-bench/apps/frappe/frappe/templates/emails/new_user.html
[2] /home/frappe/frappe-bench/apps/frappe/frappe/templates/emails/password_reset.html

However the final output should be modified even further, specially the lines with link to complete registration/password reset.
[1] a href=“{{ link }}”>{{ (“Complete Registration”) }}
[2] a href=“{{ link }}”>Reset your password

Now the link points to a server in local network (192.168.x.x) and when users click the link, for example at home, they can’t complete the process.
I’ve tried to use the automatically generated token
with the public address and it works. Though most of the users won’t be satisfied with a broken link (even if it would be possible to hack the right result out of it)

Where do I find the controller code responsible for sending the emails so I could change some details and fork it to use the static (and public) name.

I am interesting, how to do we can edit these templates?