Set Gmail as Default Mail Client in Ubuntu - Easy Guide

Setting Gmail as Your Default Mail Client in Ubuntu
For many users, Gmail is the go-to email service, and its use is almost a standard. Now, Ubuntu users can configure Gmail as their default email client without needing to install any additional software.
This functionality contrasts with Windows, which typically requires the Gmail Notifier to be installed for similar integration.
Configuration Steps
Begin by navigating to System Settings, then to Preferred Applications.
Within the Preferred Applications settings, locate the Mail Reader option. Select "Custom" from the dropdown menu.
A command window will appear. Enter the following command, remembering to replace "geek" with your actual username:
/home/geek/open_mailto.sh %s
Creating the Shell Script
Next, a shell script needs to be created and saved within your user directory ( /home/username ).
The script's content should be as follows:
#!/bin/sh
firefox https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed 's/mailto://'`
Opening in a New Tab
If you prefer the script to open a new tab within an existing Firefox window, modify the firefox line in the script to read:
firefox -remote "openurl(https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed 's/mailto://'`,new-tab)"
Hiding the Script
To conceal the script file by default, rename it by prefixing it with a period (.). For example, .open_mailto.sh. Remember to update the file path in your preferences accordingly.
Making the Script Executable
Open a terminal and execute the following command to grant the script executable permissions:
chmod u+x ~/open_mailto.sh
The configuration should now be complete and functional.
Testing the Setup
To verify the setup, click on a "contact" or "email" link on a webpage. This should immediately open a new Gmail compose window.

If you are not currently logged into Gmail, you will be prompted to enter your credentials. Following login, you may need to click the email link again, as Gmail's redirector doesn't automatically open the send mail page.
Update and Acknowledgement
The script has been updated to remove the "mailto:" tag from the URL. A significant thank you goes to Mr Linux for identifying the issue and providing the corrected script.