Dawood Sangameshwari


Open Mind, Open Source
dawood [at] dawood.in
/ :: OpenSource :: MISC :: BugZilla alerts using GMAIL

BugZilla alerts using GMAIL

This article explains how to use GMAIL SMTP(TLS AUTH) to send bugzilla alerts.
Bugzilla supports following methods to send mail alerts :
  • sendmail
  • SMTP
For SMTP method BugZilla uses Email::Send::SMTP Perl module. GMAIL SMTP uses TLS ( Transport Layer Security ) as authentication method, so Email::Send::SMTP can not be used for the same.
We need to use another perl module Email::Send::SMTP::TLS.
First step would be to install Email::Send::SMTP::TLS from CPAN. use following steps to do so :
  • using CPAN SHELL
  • Lanch CPAN shell as follows
    									perl -MCPAN -e shell
    								
    and then on CPAN Shell execute following command
    									cpan> install Email::Send::SMTP::TLS
    								
    cpan shell might ask you to install additional modules, install them.
  • compiling from source
  • Download source from HERE and execute following commands
    								tar zxvf Email-Send-SMTP-TLS-0.03.tar.gz
    								cd Email-Send-SMTP-TLS-0.03
    								./configure
    								make
    								make install
    								
Once Email:Send::SMTP::TLS is installed, BugZilla should have SMTP::TLS method to send alerts. This can be verified by logging in as admin to BugZilla and going to Administration -> Parameters -> Email
Now we need tweak BugZilla code. carefully execute following instructions and don't forget to backup files before you modify.
Go to your BugZilla installation directory and execute following command
							cd Bugzilla
						
Open Mailer.pm file.
Search for following code( should be on line # 57)
							sub MessageToMTA {
						
add following line after it
							my ($smtp_server,$smtp_port);
						
Thanks to Dilip, Sosaic, for pointing out that i forgot to declare above vars

search for following if block
							if ($method eq "SMTP") {
						
and change it to  
							if ($method eq "SMTP" || $method eq "SMTP::TLS") {
								($smtp_server,$smtp_port) = split /:/,Bugzilla->params->{"smtpserver"};
								        push @args, 
								            Host  => $smtp_server,
								            User => Bugzilla->params->{"smtp_username"},
								            Password => Bugzilla->params->{"smtp_password"},
								            Hello => $hostname, 
								            Debug => Bugzilla->params->{'smtp_debug'};
								        push @args, Port => $smtp_port if($smtp_port);
								    }   
							
Now we need to do settings in bugzilla parameters.
Login as administrator to Bugzilla and go to Administration -> Parameters -> Email and do following settings
1. Select SMTP::TLS as mail_delivery_method
2. Enter your gmail address in mailfrom
3. Enter smtp.gmail.com:587 in smtpserver
4. Enter you@gmail.com in smtp_username
5. Enter gmail password in smtp_password
6. Click on save changes
7. if you think this was useful, do consider sending a feedback :)