Configuring Jenkins email notification with gmail

2019-02-08 10:48发布

I tried to configure jenkins to send email notification with gmail as the POP provider but I could not succeed

SMTP server - pop.gmail.com
Default user e-mail suffix - @gmail.com
Sender E-mail Address - Foobar CI <your.email@gmail.com>

Use SMTP Authentication - yes
User Name - your.email
Password - p******d

Use SSL - yes
SMTP Port - 995
Reply-To Address - noreply@gmail.com
Charset - UTF-8

Test failed with : Connection refused

javax.mail.MessagingException: Could not connect to SMTP host: pop.gmail.com, port: 995; nested exception is: java.net.ConnectException: Connection refused: connect

6条回答
ら.Afraid
2楼-- · 2019-02-08 10:56

The following screenshot illustrates the e-mail configuration you'd need to do to send e-mails from GMail.

The following screenshot illustrates the e-mail configuration you'd need to do to send e-mails from GMail.

查看更多
趁早两清
3楼-- · 2019-02-08 10:57

I successfully did this with Zapier on their free tier (without having to turn on "less secure apps" in gmail

  1. Install Jenkins Notification Plugin. You might need to restart Jenkins
  2. Go to Zapier and create a Jenkins trigger
  3. In Jenkins under your project: Configure -> Job Notifications, fill in the options. Using JSON seemed to work for me.
  4. Add Gmail action in Zapier. You should be able to set this up with single sign on in your gmail account.

PS. I have no reason to recommend Zapier other than that it is working for me, and there's a solution w/o comprimising my gmail account.

查看更多
男人必须洒脱
4楼-- · 2019-02-08 11:01

The above configuration didn't work because of added security measures by google. An additional configuration is required in the Gmail account from which the mail is being triggered. This step authorizes apps like Jenkins to use the Gmail account.

https://support.google.com/accounts/answer/6010255

Go to the "Less secure apps" section in My Account. Next to "Access for less secure apps," select Turn on. (Note to G Suite users: This setting is hidden if your administrator has locked less secure app account access.)

After this emails were triggered successfully.

查看更多
家丑人穷心不美
5楼-- · 2019-02-08 11:11

Below are the updated gmail SMTP server configuration :

Gmail SMTP server address: smtp.gmail.com
Gmail SMTP user name: Your full Gmail address (e.g. example@gmail.com)
Gmail SMTP password: Your Gmail password
Gmail SMTP port: 465
Gmail SMTP TLS/SSL required: yes

This configuration is working fine for me .

查看更多
The star\"
6楼-- · 2019-02-08 11:14

The hostname for the Google SMTP server is smtp.gmail.com and if you use SSL, then the correct Port is 465.

A POP server is usually just for receiving mails, not sending mails.

查看更多
别忘想泡老子
7楼-- · 2019-02-08 11:16
  1. Obtain application specific password

    • sing-in to gmail account >> navigate to settings >> privacy and security settings

    • setup two step verification settings (because without two step verification we cannot generate application specific password)

    • after setting up two step verification setting in gmail account navigate back to security and privacy settings

    • click on application specific password >> give the name of the application in the drop down as Jenkins (google by default does not have any specific application password setting for Jenkins) >> this will generate password note down the password generated

Note : Since the Password has a overall control over you gmail account disclosing it may lead serious consequences

  1. Setup SMTP configuration for sending the gmail

    • navigate in the following path from dashboard after logging in manage Jenkins >> configure system >> scroll down to email notification section

    • enter the following parameters

      smtp server : smtp.gmail.com
      default user email suffix : @gmail.com
      
    • select advanced

    • check smtp authentication

      username : (Your gmail id)
      password : (application specific password generated from previous step)
      
    • check use SSL

      SMTP port : 465
      Reply to address : noreply@gmail.com(optional)
      Charset : UTF-8 (by default it is UTF-8)
      
    • select Test configuration mail

      Test e-mail recipient : <enter recipient email id >
      

click on test configuration which will send a test mail to the recipient e-mail id

查看更多
登录 后发表回答