In order to automatically open email (mailto:) links with Gmail in Safari, a Safari Extension must be installed.
Depending on your version of OS X / macOS, your version of Safari will support different extension types. Note: to find out what version of OS X / macOS you have, follow these instructions. To find out what version of Safari you have, open Safari, click "Safari" in the menu bar, and click "About Safari".
If you have OS X 10.10 Yosemite or OS X 10.11 El Capitan and have Safari 9, 10, or 11, you can download and install the following Safari Extension for free:
If you have macOS 10.12 Sierra or later and have Safari 12 or later, as of February 2019, a $0.99 Mac App Store app called "Open In Webmail" has been released that provides similar functionality. Note: if you attempt to install the mailto.safariextz mentioned above, you will see the following dialog informing you that the extension is no longer supported.