HOWTO: Configure Gallery2 to use gmail as a mail service

Are you running Gallery2 to host all your pictures? Are you trying to enable e-mail support via google mail? It's not working, huh?

Well... there's a way to allow users use Gallery2 to send emails via gmail. Here's how:
1) On your server, navigate to the gallery2_root/lib/smtp (in my case gallery2_root is /srv/websites/gallery2)

cd /srv/websites/gallery2/lib/smtp

2) Open smtp.php for editing

nano smtp.php

3) Find line that states:

list ($config[''], $port) = array_merge(explode(':', $config['']), array(25));

and replace it with:

$url_info = parse_url($config['']);
$config[''] = '';
if( isset($url_info['scheme']) ) {
   $config[''] = $url_info['scheme'].'://';
$config[''] .= $url_info['host'];
$port = ( isset($url_info['port']) ) ? $url_info['port'] : 25;

4) Save your file and exit editor.

Now that all the editing is out of the way, you can log in to your gallery and configure your email settings. For GMail they are as follows:
Server: ssl://
Login: (or if you are using google apps your_email@your_domain)
Password: Your password