Wednesday, May 4, 2011

Bugzilla and Gmail: Send mail notifications/alerts via Gmail

Bugzilla is an Issue Tracking System that can send email notifications to its members. Most important Bugzilla sends an Email to the bug reporter or assignee of a bug. Bugzilla does support SMTP to send email notifications. That can be set when you are logged in as an administrator under Administration > Parameters > Email.

If you want to configure Bugzilla to use Gmail you have to consider that Gmail doesn't use standard SMTP, Gmail is using SMTP with TLS. I tried this tutorial BugZilla alerts using GMAIL, but I couldn't get it running and I found it somewhat confusing.

So I digged a little deeper and came up with my own more easy solution using Email::Send::Gmail rather than Email::Send::SMTP::TLS as described in the other tutorial. The steps are done with Bugzilla running on Apache2.2 Server with a Debian Linux OS. The instructions should be similar for other Linux distributions like Ubuntu, Fedora or RedHat Linux. Be awate if you run Bugzilla on a Windows Server especially the folder structure is different.

Install the Email-Send-Gmail package for Pearl


If you have Bugzilla installed and running then you have Pearl installed properly. Start the pearl command line.
# perl -MCPAN -e shell
Run the install package command for Email-Send-Gmail.
cpan[1]> install Email::Send::Gmail
Confirm all questions with 'yes'.
If everything is done leave the command line.
cpan[2]> quit

Optional Fix: Warning (usually harmless): 'YAML' not installed...


I fixed that by entering the below command in the regular command line:
# sudo apt-get install libnet-ldap-perl

Confirm Email-Send-Gmail was installed properly


Login as administrator into your Bugzilla and go to Administration > Parameters > Email.
You should be able to select an entry called "Gmail". Select it and save the changes for now.

Change Mailer.pm


Now we need to change the Bugzilla Mailer.pm to pass on the right parameters when sending emails via the new pearl package.

Go to your Bugzilla root folder on your server. For me that is /var/www/bugzilla.
# cd /var/www/bugzilla
In the subfolder of your Bugzilla root is another folder called Bugzilla. In this folder the Mailer.pm is located. Open it with the editor of your choice, e.g. vim or nano.

# nano Bugzilla/Mailer.pm

After the last line that starts with use enter:
use Email::Send::Gmail;
use Email::Simple::Creator;

The line that says:
if ($method eq "SMTP"){
change to:
if ($method eq "SMTP" || $method eq "Gmail") {
Save your settings and you are done here.

Configure Bugzilla's Email settings


Now again as an administrator go back to Administration > Parameters > Email in your Bugzilla.

mailfrom:
username@gmail.com or username@your_domain.com (if you use your own domain via Google Applications)

smtpserver:
smtp.gmail.com

smtp_username:
username@gmail.com or username@your_domain.com (if you use your own domain via Google Applications)

smtp_password:
your Gmail password

smtp_debug:
You might want to turn on debug to see if sending mails is working. if not you should get a debug message that should help you better narrowing the error down. When everything is working you can turn debug off.

Save your changes and you are good to go. Let me know if you run into problems.

4 comments:

Anonymous said...

Thanks a lot for this.We were struggling to get SMTP authentication working for Bugzilla.Switched mailer to gmail with this module and got it working

Anonymous said...

Wow, thanks a lot! After following a bunch of other tutorials, this one is the only one that actually worked.

For anybody else wondering, I'm running a Win7x64, apache 2.2.17 with activeperl 5.12x86 system, and the method for enabling gmail above works perfectly.

Ivan Golubev said...

Thank you very much, you saved my life!!!1

I've spent the whole day reading different forums and applying various solutions to my "Windows Server 2003 + Bugzilla + Gmail" environment.

Your solution 'just works'!

Anonymous said...

THANK YOU!!!!!!!!!!!!

Post a Comment