how to configure jenkins email notifications with microsoft exchange - jenkins

Is it possible to use microsoft exchange server for email notifications in jenkins?
I have provided exchnage server name as smtp server, authentication details, selected ssl and added below argument to the command line
-Dmail.smtp.starttls.enable=true
but still getting the error javax.mail.MessagingException: Could not connect to SMTP host.

Related

Not able to send email notification in jenkins from outlook

I want to Send email in Jenkins from outlook and I have given all the setting to jenkins like smtp of outlook, smtp port number etc but still i can't send email but with gmail account I'm able to send email from jenkins.
Here is the Image of setting I used
Note: I run Jenkins Using Command java -jar jenkins.war
Here is the Error i get
Error I get
Error with TLS setting
Activate TLS as it is described on the microsoft website.
SMTP server name smtp.office365.com
SMTP port 587
SMTP encryption method STARTTLS
To activate STARTTLS start jenkins like this:
java -Dmail.smtp.starttls.enable=true -jar jenkins.war

Jenkins : poll-mailbox-trigger-plugin and SMTP

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.
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.
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:
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
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.

Jenkins email could not connect failure

I have tried with various SMTP servers but I cannot get Jenkins to send an email. I get the could not connect error - nothing else, just this error.
See the screenshot below.
Any ideas why? I am using the Jenkins docker container, firewall is off.
I do not have an email server running inside the Jenkins container. I figure I don't need one if Gmail is going to send the email for me.
Your Gmail configuration looks correct. Usually these issues come down to a firewall, but if you are sure that is not the problem it could be your Gmail account settings.
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.
Gmail - Allowing less secure apps to access your account
After performing this step emails should be triggered successfully.
UNBELIEVABLE. 2 days later. Fixed.
I found that my Cloud computing provider (Scaleway) disable outgoing SMTP by default and I had to enable SMTP via their web interface. Details here.
These commands helped me to determine that outgoing SMTP was in fact as dead as a donut:
telnet smtp.gmail.com 465
openssl s_client -connect smtp.gmail.com:587 -starttls smtp
echo "Hello world" | swaks -4 --server smtp.gmail.com:587 --from user#gmail.com --to user#example.net -tls --tls-protocol sslv3 --auth PLAIN --auth-user user#gmail.com --auth-password 7654321 --h-Subject "Test message" --body -

Fast Report export by mail using Gmail smtp

I'm using Fast Report 5 and Rad Studio Seattle and trying to send report via gmail smtp host by using Fast Report's mail export object. when i try either of the ports (465 and 587) i get an error "530. 5.7.0 must issue a STARTTLS command first". If i use a different smtp server with different settings, the report is mailed successfully.
SMTP TfrxMailExport doesn't supports SSL. Use TfrxMailExport with MAPI or MSOutlook option (mail client should be installed, configured and runned)

Jenkins e-mail notification issue / Ubuntu server issue

I'm running Jenkins 1.519 on a server with Ubuntu 13.04 and I have a problem with the e-mail notification system.
When I try to get Jenkins to send an e-mail (either the test configuration button in the manage Jenkins page, or as a build step of a job) Jenkins gives me this notification: "E-mail sent successfully", but no email is actually arriving to the recipients.
Jenkins is telling me that the e-mail notifications are working properly, but nothing is actually happening when it's supposed to. No error messages are given.
Edit:
Email settings:
SMTP server: my smtp server address
Default user e-mail suffix: -
Use SMTP authentication: check
User Name: my email username
Password: my email password
Use SSL: nope
SMTP port: 25
Reply-To Address: my email address
Charset: UTF-8
Test configuration by sending e-mail: check
Test e-mail recipient: my email address.
Edit2:
So I suppose it probably isn't necessarily a Jenkins-issue, but an issue with my server? What kind of configurations are there needed on the server side to get the email-send working? Or is the Jenkins' email-system supposed to work without hassle?
Please try to check the use SSL. Here is the Email Notification set up that's working in my system. I've also tested it in Windows, mac, and linux machines and this setup works for those systems.
Need to add proper "System Admin e-mail address" in the Configure global settings of Jenkins.
I had the same issue in Linux RedHat version 6.6 and we have found the default host and port for the SMTP is not enabled in IP table, once this is enabled it started working.
Also check if the default SMTP port is enabled in the system where jenkins is installed. This could also be the reason for failed email notification through jenkins.

Resources