Gerrit not able to send emails using Sendgrid as SMTP server

379 views
Skip to first unread message

Thiru Edla

unread,
May 26, 2021, 2:47:00 AM5/26/21
to Repo and Gerrit Discussion
Dear Team,

We are using Sendgrid as SMTP server to send emails from Gerrit. Recently Sendgrid made 2FA mandatory for authentication. Previously we were using Sendgrid username and password to authenticate from Gerrit. After the mandatory 2FA, sendgrid suggests to use username as "apikey" and password as a token.
After updating our gerrit.config file with username and token we are getting the below error
com.google.gerrit.exceptions.EmailException: Mail Error: SMTP server rejected auth: 220 SG ESMTP service ready at ismtpd0162p1iad2.sendgrid.net

Below is the sendemail configuration we are using
[sendemail]
    enable = true
    smtpServer = smtp.sendgrid.net
    smtpEncryption = ssl
    smtpUser = apikey
    smtpPass = <sendgrid token>
    smtpServerPort = 465
    from = GerritCodeReview <coder...@test.com>

By the way when we used below curl command from the same machine where our gerrit server is hosted and we received the emails.
curl -i --request POST \
--header 'Authorization: Bearer <sendgrid token>' \
--header 'Content-Type: application/json' \
--data '{"personalizations": [{"to": [{"email": "te...@gmail.com"}]}],"from": {"email": "GerritCodeReview <coder...@test.com>"},"subject": "Hello, World!","content": [{"type": "text/plain", "value": "Howdy!"}]}'

For the record the same token is being used in other tools(viz., Jenkins etc) of our organisation and things are working with the username and token.

Andrew Allen

unread,
May 27, 2021, 5:29:14 AM5/27/21
to Thiru Edla, Repo and Gerrit Discussion
On Wed, May 26, 2021 at 12:47 AM Thiru Edla <te...@gainsight.com> wrote:
Dear Team,

We are using Sendgrid as SMTP server to send emails from Gerrit. Recently Sendgrid made 2FA mandatory for authentication. Previously we were using Sendgrid username and password to authenticate from Gerrit. After the mandatory 2FA, sendgrid suggests to use username as "apikey" and password as a token.
After updating our gerrit.config file with username and token we are getting the below error
com.google.gerrit.exceptions.EmailException: Mail Error: SMTP server rejected auth: 220 SG ESMTP service ready at ismtpd0162p1iad2.sendgrid.net

Below is the sendemail configuration we are using
[sendemail]
    enable = true
    smtpServer = smtp.sendgrid.net
    smtpEncryption = ssl
    smtpUser = apikey
    smtpPass = <sendgrid token>
    smtpServerPort = 465
    from = GerritCodeReview <coder...@test.com>

Here is the sendgrid configuration I've been using for a while:

[sendemail]
smtpServer = smtp.sendgrid.net
smtpServerPort = 587
smtpEncryption = TLS
smtpUser = apikey 
from = USER 

Then I have smtpPass in the secure config file.
 
By the way when we used below curl command from the same machine where our gerrit server is hosted and we received the emails.
curl -i --request POST \
--header 'Authorization: Bearer <sendgrid token>' \
--header 'Content-Type: application/json' \
--data '{"personalizations": [{"to": [{"email": "te...@gmail.com"}]}],"from": {"email": "GerritCodeReview <coder...@test.com>"},"subject": "Hello, World!","content": [{"type": "text/plain", "value": "Howdy!"}]}'

For the record the same token is being used in other tools(viz., Jenkins etc) of our organisation and things are working with the username and token.

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/039c753e-511e-43af-9ce8-b06570c91cfbn%40googlegroups.com.

Thiru Edla

unread,
May 31, 2021, 6:58:59 AM5/31/21
to Repo and Gerrit Discussion

Thanks Andrew the solution worked.
Reply all
Reply to author
Forward
0 new messages