Tuesday, October 13, 2009

configure Bugzilla with gmail smtp

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
#cpan
capn>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
    1.tar zxvf Email-Send-SMTP-TLS-0.03.tar.gz
    2.cd Email-Send-SMTP-TLS-0.03
    3../configure
    4.make
    5.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

1.
cd Bugzilla
Open Mailer.pm file.
Search for following code( should be on line # 57)
1.sub MessageToMTA {
add following line after it

1.
my ($smtp_server,$smtp_port);

search for following if block

1.if ($method eq "SMTP") {
and change it to
01.if ($method eq "SMTP" || $method eq "SMTP::TLS") {
02. ($smtp_server,$smtp_port) = split /:/,Bugzilla->params->{"smtpserver"};
03. push @args,
04. Host => $smtp_server,
05. User => Bugzilla->params->{"smtp_username"},
06. Password => Bugzilla->params->{"smtp_password"},
07. Hello => $hostname,
08. Debug => Bugzilla->params->{'smtp_debug'};
09. push @args, Port => $smtp_port if($smtp_port);
10. }
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

It will work pretty good.




20 comments:

pravi said...

Hi,

I tried to integrate the gmail with Bugzilla, but when am trying to install the module Email-Send-SMTP-TLS-0.03 from the cpan site but i cant see the ./configure under the Email-Send-SMTP-TLS-0.03 folder.

Could you please suggest an alternate method for the same.

balaji phaneedra kumar said...

Hi, Well you said ur installing from cpan site. I hope that you know any perl module can be installed using cpan and from source. I have given method where i took source and compiled and installed it. If cpan is used just give command to install a specific module it will take care of configuring,compilations and installing.

Unknown said...

even after installing the Email-Send-SMTP-TLS-0.03 i am unable to see the SMTP::TLS option in the mail_delivery_method dropdown field.
PS: I have installed bugzilla 3.6.2 version in windows server 2003 system.

Rocky said...

Thanks for this post. I faced two problems, but solved them easily:
- First one, I had to run cpan as root (with sudo, under Ubuntu)
- Second, I had to install Authen::SASL from cpan, since it was not installed as a dependency for Email::Send::SMTP::TLS

After that, everything worked!

Dawood Sangameshwari said...

Hey,
this is great article. But, did you know that i am the original author of it? I hope your intension was to spread the tutorial.. it would be great if you learn to give credit to original author.

balaji phaneedra kumar said...

TO Dawood,
Oh!!! great work man. My intension to spread the information I know and collect all info and place at a place on net. I fell blog is best place to share and make a collection.
Once again thanks for your article..
Sorry I don't remember your blog, I feel good if you provide you blog info... I will be your follower.... :)

Rasna said...

Hi Dawood,

Thank you for the detailed description. Eventhough I followed your document the "SMTP::TLS" is not getting listed under mail_delivery_method.

Can you please help me on this.

Regards,
Rehana

balaji phaneedra kumar said...

How did u installed it using cpan or source. If it is a source you need to look at the dependencies. Better use cpan.

Rasna said...

Hi,

I have done it through CPAN,Can you please tell me a solution for this.Do i need to modify teh TLS file.

Regards,
Rehana

balaji phaneedra kumar said...

No need to do any changes to TLS file but have you done changes to mailer.pm as I mentioned above.

Rasna said...

Hi,

I have done that but it is giving me the following error in the bugzilla browser:

Software error:
Can't locate Email/Send/SMTP/TLS.pm in @INC (@INC contains: . lib E:/Bugzilla/perl/perl/lib E:/Bugzilla/perl/perl/site/lib) at Bugzilla/Mailer.pm line 54.
BEGIN failed--compilation aborted at Bugzilla/Mailer.pm line 54.
Compilation failed in require at Bugzilla/Auth.pm line 35.
BEGIN failed--compilation aborted at Bugzilla/Auth.pm line 35.
Compilation failed in require at Bugzilla.pm line 40.
BEGIN failed--compilation aborted at Bugzilla.pm line 40.
Compilation failed in require at E:/Bugzilla/bugzilla/admin.cgi line 26.
BEGIN failed--compilation aborted at E:/Bugzilla/bugzilla/admin.cgi line 26.

For help, please send mail to the webmaster (admin@example.com), giving this error message and the time

Any idea about this....

Regards,
Rehana

balaji phaneedra kumar said...

This problem looks like modules that are installed are not visible to bugzilla or not installed properly (deps are missing). I used bugzilla 3.2 and worked fine.
Can't locate Email/Send/SMTP/TLS.pm means check TLS.pm is there in ur PC and check the location where buzilla looking and where perl installed it.

I hope it resolves

Rasna said...

Hi,

Can anyone tell me how do we remove the unwanted fields from the bugzilla mail notification.

Thanks in advance,

Regards,
Rasna

balaji phaneedra kumar said...

I didn't exactly do this but I hope this file give do.

bugzilla/build/Email-Send-SMTP-TLS-0.03/lib/Email/Send/SMTP/TLS.pm

Or need to track email notification method that ur using (here TLS). I Hope, I have given clue.

Anonymous said...

works thanks !

sachin said...

Hi This is sachin from pune
i have 1 issue i have install Bugzilla 3.6 Release install done
on windows 2008 server
my problem is after assign bug my user not getting mail from bugzilla we are using google apps my smtp server is SMTP.GMAIL.COM
PLEASE HELP ME HOW TO CONFIGURE ON WINDOWS SYSTEM

Unknown said...

Software error:

Connect failed :IO::Socket::INET: connect: Permission denied
at /usr/local/share/perl5/Email/Send/SMTP/TLS.pm line 45


Please help me...

Unknown said...

Hi Balaji,

I followed the same configuration steps.
Bugzilla 4.2.4
OS-Windows server 2008
Please follow the link below with error snapshot which I'm facing.

http://mozilla.6506.n7.nabble.com/SMTP-TLS-error-after-configuring-td262481.html

Thanks in advance,
Santosh

Allen said...

These instructions worked perfectly. The from address must be legitimate, not mailer-daemon, but the instructions said so.

My hosting service is Dreamhost. I installed Bugzilla very vanilla from their instructions. Painless.

SQL Knowledge said...

@suvedhu found any solutions? even after installing module, I am not able to see SMTP:TLS in configuration