Gerrit cannot use Gmail SMTP Server

6,024 views
Skip to first unread message

Amrullah

unread,
Jun 16, 2011, 10:53:45 AM6/16/11
to repo-d...@googlegroups.com
Hi Guys,

I have a problem setting [sendemail] configuration in Gerrit. I tried to use below configuration.

[sendemail]
        smtpServer = smtp.gmail.com
        smtpServerPort = 587
        smtpEncryption = SSL
        sslVerify = false
        smtpUser = amr_bla...@gmail.com
        smtpPass = password_bla_bla_bla

I got below error when trying to change my preferred email in Gerrit site: http://127.0.0.1:8080/#settings,contact

-----------------------------------------------------------------------
[2011-06-16 22:44:20,489] ERROR com.google.gerrit.httpd.rpc.account.AccountSecurityImpl : Cannot send email verification message to nga...@yahoo.com
com.google.gerrit.server.mail.EmailException: Unrecognized SSL message, plaintext connection?
    at com.google.gerrit.server.mail.SmtpEmailSender.open(SmtpEmailSender.java:245)
    at com.google.gerrit.server.mail.SmtpEmailSender.send(SmtpEmailSender.java:152)
.......
........
....
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:542)
    at sun.security.ssl.InputRecord.read(InputRecord.java:374)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:818)

Actually I can do workaround by updating ACCOUNTS and ACCOUNT_EXTERNAL_IDS tables. However, I am curious how to set the things up correctly.

Thank you,

Amru

Shawn Pearce

unread,
Jun 16, 2011, 11:49:56 AM6/16/11
to Amrullah, repo-d...@googlegroups.com
On Thu, Jun 16, 2011 at 07:53, Amrullah <amrullah...@gmail.com> wrote:
> I have a problem setting [sendemail] configuration in Gerrit. I tried to use
> below configuration.
>
> [sendemail]
>         smtpServer = smtp.gmail.com
>         smtpServerPort = 587
>         smtpEncryption = SSL
>         sslVerify = false
>         smtpUser = amr_bla...@gmail.com
>         smtpPass = password_bla_bla_bla
...
> Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext
> connection?

This sounds like you have tried to use SSL, but the Gmail port you are
connecting to isn't speaking SSL.

I don't actually know how to connect Gerrit directly to Gmail. One of
my own servers does use Gmail for outbound email, but it does it
indirectly through Postfix. The server is running Postfix, and Gerrit
uses the local Postfix SMTP server as its relay. Postfix then forwards
all outgoing email through the Gmail SMTP servers. There are
instructions available on the web on how to configure a Postfix server
to relay through Gmail.

It should work to connect Gerrit directly to Gmail, did you try
smtpEncryption = TLS?

Rob Heittman

unread,
Jun 16, 2011, 12:08:16 PM6/16/11
to Shawn Pearce, Amrullah, repo-d...@googlegroups.com
The direct connection information is in this old thread:


What you want is:

smtpServerPort = 465 
smtpEncryption = SSL
 

What you *really* want is a local mail daemon like Postfix configured to relay through GMail ... otherwise you will encounter significant delays whenever Gerrit blocks to send email, which is, well, a lot ... but this will get you up and running quickly.

Amrullah Syadzili

unread,
Jun 16, 2011, 12:34:01 PM6/16/11
to repo-d...@googlegroups.com
I tried all the combination of ports (465, 587) and encryption (ssl, tls) but it still didn't work. The error were either "Unrecognized SSL message, plaintext connection?" or "Connection time out".

My thunderbird settings are 587 - STARTTLS and it works.


>>The direct connection information is in this old thread:
I found the thread yesterday unfortunately it didn't solve my problem. Probably it doesn't apply to Gerrit I'm using (gerrit 2.2.1).

Actually what I really need is people can register to my Gerrit installation. As we know that a user needs email address to be registered to Gerrit to be able to push code. I am thinking to bypass the Email Confirmation link so user can put his/her email right the way. Would like to know if somebody else has encountered this situation.

Thanks,

Rob Heittman

unread,
Jun 16, 2011, 1:06:17 PM6/16/11
to Amrullah Syadzili, repo-d...@googlegroups.com
Hmm. 465 should go with SSL, 587 goes with TLS. A restart is needed to pick up the settings. I can only actually vouch for it working up to 2.1.6.1 though -- I haven't worked with 2.2 yet.

Can you use OpenID for the registration process?

For a low volume installation, you could try SendGrid as an alternative email service with minimal configuration and no SSL/TLS requirement. A free account will send a few emails a day, or you can pay to upgrade to the capacity you need. Their SMTP intake is fast enough that you needn't run a local mail daemon, though it's still likely to be faster and better if you do.

Amrullah Syadzili

unread,
Jun 16, 2011, 7:14:08 PM6/16/11
to Rob Heittman, repo-d...@googlegroups.com
Still No luck. I retried using port 465 - ssl but it didn't work. I registered to sendgrid and change my gerrit.config file to:


[gerrit]
    basePath = git
    canonicalWebUrl = http://localhost:8080/
[database]
    type = H2
    database = db/ReviewDB
[auth]
    type = OPENID
[sendemail]
    smtpServer = smtp.sendgrid.net
    smtpUser = amru...@panemu.com
    smtpPass = password_bla_bla_bla
[container]
    user = hahach
    javaHome = /usr/lib/jvm/java-6-openjdk/jre
[sshd]
    listenAddress = *:29418
[httpd]
    listenUrl = http://*:8080/
[cache]
    directory = cache

I stopped gerrit and restarted it again to apply the change. Still I got Connection timed out.

[2011-06-17 06:59:07,885] ERROR com.google.gerrit.httpd.rpc.account.AccountSecurityImpl : Cannot send email verification message to ngam...@yahoo.com
com.google.gerrit.server.mail.EmailException: Connection timed out
    at com.google.gerrit.server.mail.SmtpEmailSender.open(SmtpEmailSender.java:245)

I have ensured that I can log in to sendgrid website using the username and password.

I tried OpenID. Since I was the first to register, I became the Administrator and my open id account (gmail account) was registered as preferred email. Strangely, when I signed out and registered using yahoo open id, I was registered but gerrit didn't register my yahoo email as preferred email. It was blank.

I also checked many log files but didn't find any suspicious. I am using ubuntu 10.10 and 11.04.

thanks,

Amru

Rob Heittman

unread,
Jun 16, 2011, 7:24:37 PM6/16/11
to Amrullah Syadzili, repo-d...@googlegroups.com
Can you rule out a TCP issue by verifying, on the Ubuntu server, that something like "telnet smtp.sendgrid.net 25" works to make a connection? Or, for that matter "telnet smtp.gmail.com 465" ... there may be other issues affecting your ability to send mail. Feel free to contact me directly if I can help troubleshoot this without spamming the list.

Amrullah Syadzili

unread,
Jun 17, 2011, 8:47:50 AM6/17/11
to Repo and Gerrit Discussion
I go with Rob's suggestion and it worked.

smtp.sendgrid.net, port 587, no encryption, solved my problem.

You'r rock man! Many thanks.

Btw, sendgrid provide 200 mail /day for free account.

B.TEJESh KUMAR

unread,
Jun 20, 2011, 2:48:42 AM6/20/11
to Amrullah Syadzili, Repo and Gerrit Discussion
Hi all,
 
In Gerrit,
 
i have cloned my gerrit repo
git clone ssh://user@xyz:29418/reponame.git
 
made some changes and commited the changes
 
i just pushed the changes to gerrit.
 
the command i have used git push ssh://user@xyz/reponame:29418/reponame HAED:refs/for/master 
up to now done successfully.
 
but i need to push these changes to my git repository in the server.
 
can any one specify the command for that?
 
when i am pushing it to my git server using the command git push origin master
 
it was showing an error
 
$ git push ssh://user@xyz:29418/testing  HEAD:refs/heads/master
Total 0 (delta 0), reused 0 (delta 0)
To ssh://user@xyz:29418/testing
 ! [remote rejected] HEAD -> master (prohibited by Gerrit)
error: failed to push some refs to 'ssh://user@xyz:29418/testing'


 

Magnus Bäck

unread,
Jun 20, 2011, 3:15:37 AM6/20/11
to Repo and Gerrit Discussion
On Monday, June 20, 2011 at 08:48 CEST,
"B.TEJESh KUMAR" <tejeshku...@gmail.com> wrote:

> In Gerrit,
>
> i have cloned my gerrit repo
> git clone ssh://user@xyz:29418/reponame.git
>
> made some changes and commited the changes
>
> i just pushed the changes to gerrit.
>
> the command i have used git push ssh://user@xyz/reponame:29418/reponame
> HAED:refs/for/master
> up to now done successfully.
>
> but i need to push these changes to my git repository in the server.
>
> can any one specify the command for that?
>
> when i am pushing it to my git server using the command git push origin
> master
>
> it was showing an error
>
> $ git push ssh://user@xyz:29418/testing HEAD:refs/heads/master
> Total 0 (delta 0), reused 0 (delta 0)
> To ssh://user@xyz:29418/testing
> ! [remote rejected] HEAD -> master (prohibited by Gerrit)
> error: failed to push some refs to 'ssh://user@xyz:29418/testing'

By default, users don't have permissions to bypass review. To be
able to push to refs/heads/branchname you'll have to grant yourself
at least Push Branch +1 in your git.

--
Magnus Bäck Opinions are my own and do not necessarily
SW Configuration Manager represent the ones of my employer, etc.
Sony Ericsson

B.TEJESh KUMAR

unread,
Jun 20, 2011, 4:42:39 AM6/20/11
to Repo and Gerrit Discussion
Hi,
 
i am the admin user but i didn't got anything how can we grant Push branch +1 permission in our git
 


 

--

B.TEJESh KUMAR

unread,
Jun 20, 2011, 5:58:37 AM6/20/11
to Repo and Gerrit Discussion
Hi,
 
Can u please clearly specify how can we do this?

Luthander, Fredrik

unread,
Jun 20, 2011, 6:06:55 AM6/20/11
to B.TEJESh KUMAR, Repo and Gerrit Discussion
Hi there Tjejesh!

It helps us if you tells us what kind of research you have performed before asking this of us. That way we know what else you may need, if the documentation of the tool is not clear, and so on.

I presume you have read up on the documentation of the tool, for instance this page is a good read:
https://review.source.android.com/Documentation/access-control.html

To find where to set these settings, please login to your Gerrit instance with administrative privileges and click Admin -> Projects -> The git you want to change ACLs on -> Access
That view will give you an overview over current rules, and give you the possibility to add or remove rules according to your needs.

If you need more help, please feel free to ask again, but also remember to include what you have already tried and what you have already read on the subject - that will make it easier for us to help you with your problem!

--
Best regards,
    Fredrik Luthander
Sony Ericsson Mobile Communications AB

B.TEJESh KUMAR

unread,
Jun 20, 2011, 7:55:10 AM6/20/11
to Luthander, Fredrik, Repo and Gerrit Discussion
Hi,
 
i have read the doc but i didn't got the PUSH BRANCH label in gerrit add permission list.
 
i have pushed the changes into HEDA:refs/for/master but i need push this chnges  to git server after verfying & code reviewing.
 
Please tell me if any one knows  it.

Magnus Bäck

unread,
Jun 20, 2011, 9:01:24 AM6/20/11
to Repo and Gerrit Discussion
On Monday, June 20, 2011 at 13:55 CEST,
"B.TEJESh KUMAR" <tejeshku...@gmail.com> wrote:

> i have read the doc but i didn't got the PUSH BRANCH label in gerrit
> add permission list.
>
> i have pushed the changes into HEDA:refs/for/master but i need push
> this chnges to git server after verfying & code reviewing.
>
> Please tell me if any one knows it.

We understand what you're having problems with, but neither I nor
Fredrik seem to understand what's difficult about adding the required
permission.

Go to Admin -> Projects and locate your project (or pick "-- All
projects --" if you want the modify the default permission for
projects). At the bottom of the Access pane, add a Push Branch +1
permission for the group that should be granted this extra permission.
The Reference Name field can be refs/heads/*.

B.TEJESh KUMAR

unread,
Jun 20, 2011, 9:11:06 AM6/20/11
to Repo and Gerrit Discussion, magnu...@sonyericsson.com
Hi,
 
i am using gerrit 2.2.1 version
 
In , the add permission drop down list there is PUSH BRANCH label
Below is my drop down list regarding push labels:
 
Push,
Push merge commit,
Push anotated tag


 

B.TEJESh KUMAR

unread,
Jun 20, 2011, 9:17:24 AM6/20/11
to Repo and Gerrit Discussion, magnu...@sonyericsson.com


Hi,
 
 Pls ignore previous mail
 
 
i am using gerrit 2.2.1 version
 
In , the add permission drop down list there is no PUSH BRANCH label

B.TEJESh KUMAR

unread,
Jun 21, 2011, 12:39:07 AM6/21/11
to Repo and Gerrit Discussion, magnu...@sonyericsson.com


Hi,
  
 
i am using gerrit 2.2.1 version
 
In , the add permission drop down list there is no PUSH BRANCH label
Below is my drop down list regarding push labels:
 
Push,
Push merge commit,
Push anotated tag


Shawn Pearce

unread,
Jun 21, 2011, 10:06:43 AM6/21/11
to B.TEJESh KUMAR, Repo and Gerrit Discussion, magnu...@sonyericsson.com
On Mon, Jun 20, 2011 at 06:11, B.TEJESh KUMAR
<tejeshku...@gmail.com> wrote:
> i am using gerrit 2.2.1 version
>
> In , the add permission drop down list there is PUSH BRANCH label
> Below is my drop down list regarding push labels:
>
> Push,
> Push merge commit,
> Push anotated tag

Push Branch +1 was renamed in Gerrit 2.2.0 to just Push. Magnus is
looking at a 2.1.x server, which uses a slightly different UI and
terminology for the same concepts as the newer 2.2 series.

B.TEJESh KUMAR

unread,
Jun 28, 2011, 1:10:33 AM6/28/11
to Shawn Pearce, Repo and Gerrit Discussion
Hi all,
 
 
Can any one tell me how can we use http authentication in detail than OPENID?

B.TEJESh KUMAR

unread,
Jun 28, 2011, 3:06:14 AM6/28/11
to Shawn Pearce, Repo and Gerrit Discussion
Hi all,
 
We have a problem that we have  cloned a project using git, but just now we are using gerrit.
 
we can push the changes to git directly using command "push origin XYZ".
can we restrict this push using gerrit?

Magnus Bäck

unread,
Jun 28, 2011, 3:35:54 AM6/28/11
to Repo and Gerrit Discussion
On Tuesday, June 28, 2011 at 09:06 CEST,
"B.TEJESh KUMAR" <tejeshku...@gmail.com> wrote:

> We have a problem that we have cloned a project using git, but just
> now we are using gerrit.
>
> we can push the changes to git directly using command "push origin
> XYZ". can we restrict this push using gerrit?

Can you please stop reusing old threads for new topics? Just send
a new email to repo-d...@googlegroups.com with a new subject,
or use the "new post" button on the web page.

Disallowing direct pushes is the Gerrit default. The other week you
asked how to remove this restriction, and we told you how to do so.
Now you want the restriction back again?

Mohan .S

unread,
Feb 20, 2017, 5:35:49 AM2/20/17
to Repo and Gerrit Discussion, amrullah...@gmail.com
Hi Amrullah,

I am facing the problem with Gerrit email notification.

Please refer the below link for details about problem.

https://groups.google.com/forum/#!msg/repo-discuss/MkODFXIo2I0/ER4sZYqfDAAJ;context-place=searchin/repo-discuss/Connection$20reset%7Csort:relevance

Kindly share your working [sendemail] configuration from gerrit.config file. it would help me a lot.

Thanks,
Mohan

Antonio Leite

unread,
Dec 27, 2019, 1:40:27 AM12/27/19
to Repo and Gerrit Discussion

Here is my configuration for
Gmail
Account 96540...@gmail.com Security

Signing in to Google

Use your phone to sign in: Off
2-Step Verification: Off
Less secure app access: On

etc/secure.config (Key generated upon installation)
[auth]
    registerEmailPrivateKey = KCTsFX2tSW1FlYI5+gSIiIkH12DcmDNbRqQ=

etc/gerrit.config
...
[sendemail]
    enable = true
    sslVerify = false
    from = USER

    smtpServer = smtp.gmail.com
    smtpServerPort = 587
    smtpEncryption = TLS
    smtpUser = 96540...@gmail.com
    smtpPass = password
...


When pushing I used these commands
git add code-review-sample.txt
git commit -m "Review 11"
git push origin HEAD:refs/for/master%topic=Topic1,r=96540...@gmail.com

r = reviewer email

Upon reception of the commit, 96540...@gmail.com received this message



from:    Administrator <96540...@gmail.com>
reply-to:    antlei...@gmail.com,96540...@gmail.com
to:    965407636a <96540...@gmail.com>
cc:    Administrator <antlei...@gmail.com>
date:    Dec 26, 2019, 5:44 PM
subject:    Change in hello-project[master]: Review 11
mailing list:    <gerrit-hello-project.PC> Filter messages from this mailing list
mailed-by:    gmail.com
signed-by:    gmail.com
security:    Standard encryption (TLS) Learn more


Subject:
Change in hello-project[master]: Review 11

Message:
Administrator would like 965407636a to review this change.

View Change

Review 11

Change-Id: I626f2780330e149664e600d0f10e8bce23e88123
---
M code-review-sample.txt
1 file changed, 1 insertion(+), 0 deletions(-)

git pull ssh://PC:29418/hello-project refs/changes/81/181/1

To view, visit change 181. To unsubscribe, or for help writing mail filters, visit settings.



In http://pc:8080/admin/repos/All-Projects,access
Click Edit
Goto Reference: refs/meta/config
In Read move button Exclusive to left
Click Save

Environment

release Gerrit 3.1.2 from
http://gerrit-releases.storage.googleapis.com/index.html

Xubuntu 16.06 LTS



Hope this help

Best wishes








Reply all
Reply to author
Forward
0 new messages