1

I am unable to get Jenkins to build based on an email using the poll-mailbox-trigger plugin

My setup in E-mail Notification is as follows

  • SMTP server: myExchangeServerHostName
  • Default user e-mail suffix: @companyName.com
  • Use SMTP Authentication: True
  • User Name: DOMAIN\user
  • Password: aboveUserPassword
  • Use SSL: False
  • SMTP Port: 587
  • Reply-To Address:
  • Charset: UTF-8

From here I can successfully send a test email to myself and I receive it.

In my build the Poll Mailbox Trigger settings are as follows

  • Host: myExchangeServerHostName
  • Username: DOMAIN\user
  • Password: aboveUserPassword
  • Advanced Email Properties:
    • mail.imaps.port=587
    • mail.imap.ssl.enable=true
    • mail.imap.starttls.enable=true
  • Schedule: H/5 * * * *

When Testing this connection I get

Connecting to the mailbox... Error : javax.mail.MessagingException: Unrecognized SSL message, plaintext connection?; nested exception is: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:665)

I have tried

  • mail.imap.ssl.enable=false
  • using the email address instead of the domain\user
  • adding mail.imaps.ssl.trust=*

None of the above seem to make any difference.

russelrillema
  • 452
  • 7
  • 14
  • I have made some more changes like enabling tls when Jenkins starts up and adding the correct port number but when clicking Test Connection I now get Error : javax.mail.MessagingException: Unrecognized SSL message, plaintext connection?; Send test email from the Configure System page works. – russelrillema May 26 '17 at 05:05
  • Hi, have you got the correct connection settings? What have you tried to verify these? There's some troubleshooting steps here -> https://github.com/jenkinsci/poll-mailbox-trigger-plugin/#troubleshooting . Please try them first, then let us know how you went. – Nick Grealy May 26 '17 at 05:50
  • Hi, I have run through all those steps. None of them relate to the error I am receiving. I can telnet and I am using the same credentials as I am using in the E-mail Notification section of the system Configuration page. On this page I can send a test email and it goes through successfully. I will update the question now with all the setting I have in E-mail Notification and in the Poll Mailbox Trigger – russelrillema May 26 '17 at 06:12
  • The same issue I am facing, In my org I have SMTP server but using that I can't able to communicate getting Test Connection Connecting to the mailbox... Error : javax.mail.MessagingException: Connection refused: connect; nested exception is: java.net.ConnectException: Connection refused: connect at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:665) at javax.mail.Service.connect(Service.java:295) – Shankar Oct 11 '18 at 15:25

2 Answers2

0

SMTP protocol is for sending and relaying mails. With this protocol one cannot retrieve mails from a particular mailbox. Whereas IMAP and POP3 protocols can retrieve mails.Therefore you will have to obtain access to the IMAP or POP3 server in order to retrieve mails. The poll mailbox trigger plugin of jenkins tries to connect to mailbox via IMAP store. If the mail server is using HTTPS protocol like in an Exchange server, you can write a powershell utility using Microsoft EWS managed api, to retrieve mails and plug that utility into jenkins. Also, Powershell scripts can be included in batch scripts as well which can then be included in jenkins.

0

The problem might relate to the certificate on the mail server (self signed one, and not recognized by Jenkins and the plugin), so registering the certificate to your trustStore would help.

I found 2 working solutions:

  1. Add the certificate of your mail server, following 'Highway of Life' instruction in Jenkins "unable to find valid certification path to requested target" error while importing Git repository

  2. Change trustStoreType to Windows-Root so Jenkins would use the same certificate source as your browser, answer from 'Nux' here, How to configure trustStore for javax.net.ssl.trustStore on windows?

Note: solution 1), there were same answer but exporting the certificate from browser instead of using 'openssl', somehow it did not work for me or I did it wrong. So you may try both.