To save all the hassle, I would highly recommend adding your webmail mailbox as IMAP to a mail client locally.
That being said, there are are few ways to go about this.
replacing https://mail.google.com/mail?view=cm&tf=0&to=echo $1 | sed 's/mailto://'
with your webmail address. e.g: http://webmail.com/composerpage?to=echo $1 | sed 's/mailto://'
Whether your webmail address can handle the to argument or not is another question however. I would look into documentation of your webmail client, or try manually putting a [email protected] in the url when visiting your webmail
Note: this method assumes you're using thunderbird and firefox as your default mail and web clients respectively.
2 - Setting an app as an executable, setting that app as your default mail client
There's a couple ways of doing so, but the easiest in my experience is using Nativefier which uses electron
an example command you'd use to set up the app is:
mkdir ~/app
nativefier -n webmail http://webmail.com/composerpage --internal-urls ".*?\.webmail.com\.*?" --basic-auth-username username --basic-auth-password password ~/app
you can then open your mail client via it's own app
You can then change your default mail client in firefox
Click the menu button and select options
In the General panel, go to the Applications section.
Search for the Content Type mailto and select it.
Click on the Action column in the mailto row to change the action.
select Use other...
enter /home/<user>/app/webmail-linux-x64/webmail
This method however won't populate the to field unfortunately. You could build the app using electron manually to accept a to argument
3 using a browser plugin to change mailto functionality
I can only find a chrome extension that looks to do the trick but cannot vouch for it:
https://chrome.google.com/webstore/detail/mailto/gppbppehiogfokmpligejhaepeopajdf?hl=en-GB
note that using a third-party plugin does pose it's security risks so I would avoid this option if possible.