How can I set the Sender's address in Jenkins? - email

I'm sending mail from Jenkins to an anonymous SMTP relay internally. That relay then securely sends mail to exchange online via TLS on port 587. The transport works perfectly, the issue is that Microsoft requires the Sender address match the authentication credentials login name which is the same as the account email address. For example sake, say this is foo#mycompany.com. How can I make jenkins always send mail from foo#mycompany.com?
BTW when I say the transport works perfectly what I mean specifically is that I can drop a formatted e-mail file into the "Pickup" directory on the SMTP relay server and it is properly sent to any recipient provided the From address is foo#mycompany.com.

Jenkins uses the System Admin e-mail address as the sender address for e-mail notification. You can configure this under Manage Jenkins -> Configure System. This is under the Jenkins Location header on that page! It is not immediately obvious that this setting is tied to the e-mail notification settings, since it is not under the E-mail notification header on the configuration page.

Manage Jenkins -> Configure System -> Jenkins Location -> System Admin e-mail address
You can search the page for "Jenkins Location" to change the default value of address not configured yet to whatever you want.

There are two places to add the "E-Mail Notificaitons"
Global level
Local level (Jenkins job level)
To set the E-Mail Notification at Global Level, follow below steps -
1) Go to Manage Jenkins
2) Configure System
3) Jenkins Location
4) System Admin e-mail address
To set the E-Mail Notification at local level (per Jenkins job level), follow below steps -
1) Click on the Job name (if existing one)
2) click on the "Configure"
3) Then look for the "Post-build Action"
4) Specify the email address under "E-mail Notification".
5) Save the changes.

I'm not sure if it is what you meant, but Jenkins enables you to provide a full Sender E-mail Address for notifications. Go to Manage jenkins, then System configuration and find section called E-mail Notification.
You can provide you email address in a form of Jenkins <foo#mycompany.com>.

If you need to do this without using the jenkins UI (for instance in automating a jenkins setup) - you can do so with a groovy script.
import jenkins.model.*
def jenkinsLocationConfiguration = JenkinsLocationConfiguration.get()
jenkinsLocationConfiguration.setAdminAddress("[your admin name] <[your admin email address]>")
// example format -> .setAdminAddress("Jane Doe <foo#company_email.com>")
jenkinsLocationConfiguration.save()
Do note: I did not write this script (although I have tested it and it works), all credit to Peter Halliday and his website with other helpful groovy scripts here.

import javax.mail.Message.RecipientType
import javax.mail.Address
import javax.mail.internet.InternetAddress
import javax.mail.internet.MimeMessage
msg.setFrom(new InternetAddress("john...#server.com"))

Related

Github PAT creation triggers 2 emails, is it a security issue?

I am receiving 2 emails about the creation of PAT, is it a security vulnerability? or a Bug?
Note: I have 2 emails attached to my GitHub account (both emails configured to same mailbox, means those are alias emails) and we use GitHub Enterprise Server (not cloud)
I found the solution, it's a feature, by default security-relevant mails are sent to backup email Id, it can be changed in profile -> Email -> Backup Email Address.
GHES version: 3.2.9
Adding it as this may help someone. Have a nice day.

Getting issues via email stopped working after email account password update

We had a fully working Jira Service Desk installation (JIRA Service Desk Application v3.6.1) for years and on Friday we changed the password of the associated email account ithelp#...
Once the change was done on the Exchange server we updated the password on system-Outgoing Mail and system-Incoming Mail, provided the latest password by clicking on checkbox adjacent to Change Password. After entering the password, click on Update button.. The test in both cases says its working.
If we check Mail audit log for ithelp#... then we see.
If we do a test there then:
And the "view log" shows:
What have we tried?
We went through https://confluence.atlassian.com/jirakb/troubleshooting-jira-service-desk-incoming-mail-790960076.html?_ga=2.74568658.1933816762.1551665594-977289960.1550604024 without success.
Restarting Tomcat.
Rebooting the server.
Deleting and recreating the configuration for IMAP.
Configuring the IMAP settings using IP instead of server name.
If you know what could be the problem or if you know what we are missing your help is greatly appreciated.
Thanks in advance,
Log into Jira Service Desk with elevated rights. (administrative rights)
Select projects -> IThelp
Select email requests.
Under custom email addresses click the edit.
Change the password to the new password set for IThelp. Click next
Select the email request type as Email Request

How do I send a email on jekins for any build failure on the server

Our jenkins server has a lot of jobs, is there anyway to configure so that an email is sent when any build breaks? I know how to do it for each job individually, but I'd like to set up a global configuration.
We use the Email Extension Plugin.
and then configure our SMTP Server in the General Configuration.
Once this is all setup, then add a Post Build event in your Jenkins job to send an email on failure.
We ended up using this https://wiki.jenkins-ci.org/display/JENKINS/Configuration+Slicing+Plugin
There is a way to configure emails for all jobs at once

How to disable email confirmation in gitlab

I set up a gitlab server in ubantu14.4.3SLT
in my case, I want to set up a git server for local users so I do not need user to sign in with any email confirmation.
How can I disable email confirmation in gitlab? are there any api or something simple to disable it?
This isn't a good answer. But ran across this and wanted to skip for a test instance I have. This is what I did(gitlab 10.1.0):
From the rails console:
User.all.each {|u| u.confirmed_at = Time.now; u.save}

jenkins Extended E-mail Notification: ${BUILD_URL} 's port is wrong

I use the Extended E-mail Notification to set the mail notification. The tomcat default port is 8080, but I change to 9080.
I visited jenkins with this URL: http://*.*.*.14:9080/jenkins/configure
Now I set Extended E-mail Notification default content. Here is the code:
build result (For xxx) - "${PROJECT_URL}ws"${PROJECT_URL}
SVN Url "${BUILD_URL}${BUILD_URL}
When I see the mail, the url port is not 9080, but 8080.
http://*.*.*.*:8080/jenkins/job/FinanceSys/70/
Does anyone know why?
Go to Manage Jenkins -> Configure System, locate the "Jenkins Location" section and make sure that the Jenkins URL is setup properly. I believe that value is what the Extended Email Notification plugin uses, not the URL you are using to access Jenkins in the browser.
For example, you could access Jenkins with "localhost:8080", but the emails get generated with "my.company.com:8080" - because that's what the Jenkins URL is set to.