Email Notification in Jenkins
A friendly, step-by-step guide to how Jenkins sends emails about your builds, who should receive them, what they should say, and how to keep them useful instead of noisy.
Imagine a smoke alarm in your kitchen. If it stays silent while the toast burns, it is useless. If it screams every time you boil an egg, you will soon take out the battery, and then it is useless again. A good alarm speaks up at the right moment, to the right person, with a message that says what is wrong.
Jenkins builds and tests software around the clock, and most of the time nobody is watching the screen. So when something breaks, Jenkins needs a way to tap a person on the shoulder. One of the oldest and most common ways is email notification. In this guide you will learn what email notification in Jenkins is, how to connect Jenkins to a mail server, how the two main email plugins differ, how to choose who gets which message and when, how to keep secrets safe, and how to fix things when emails never arrive. No earlier knowledge is needed, and every new word is explained the first time it appears.
1What Is Email Notification in Jenkins?
Email notification is the feature that lets Jenkins send an email message to people when something happens to a build.
Start with the word build. A build is one run of a Jenkins job: fetch the code, compile it, test it, package it. Each build ends with a result, such as success or failure. Email notification is the messenger that carries that result to human inboxes.
A typical message might say, “The build of the online shop failed. Here is the link to the log. These two people changed the code since the last good build.” The person who receives it can open the link, see what went wrong, and start fixing it, without ever having sat in front of Jenkins.
The main questions email notification answers
- When? After every build, only after failures, only when the status changes, or only when something is fixed.
- Who? A fixed list of people, the developers whose code changed, the person who started the build, or a mix.
- What? A short subject line and a body with the result, a link, a summary of changes, and perhaps the log.
- How? Through a mail server that Jenkins is allowed to use.
Think of a school that sends a message to parents. It must know the parents’ addresses, have a working postal service, decide when to write (only for important news, not every hour), and write a clear letter. Jenkins email notification is that school office for your builds.
2Why Email Notification Matters
Automation only helps if people find out quickly when it needs them.
Picture a team of twenty developers pushing code all day. Jenkins tests every change. One change quietly breaks the login page. If nobody notices for three hours, more changes pile on top, the cause becomes harder to find, and the fix becomes more expensive. If Jenkins emails the responsible developer within minutes, the mistake is still fresh and the repair is often a five-minute job.
Email notification gives four gifts. First, speed: people learn about problems in minutes. Second, focus: the right person hears about it, not everyone. Third, a record: emails are stored in inboxes and can be searched later. Fourth, reach: people who never open Jenkins, such as managers or testers, still stay informed.
A notification is only useful if it is read. Aim for messages that are rare enough to be taken seriously and clear enough to be acted on within a minute.
3Core Concepts You Must Know
A handful of words unlock everything about email in Jenkins. Learn these and the rest feels natural.
SMTP
Simple Mail Transfer Protocol, the standard way programs hand an email to a mail server for delivery. Jenkins talks to an SMTP server to send messages.
Mail server
The computer that accepts emails and delivers them. It may belong to your company or to a service such as a cloud email provider.
Port
A numbered door on a server. Mail servers commonly use door 25, 465, or 587, each with slightly different rules for security.
SSL and TLS
Ways of scrambling the connection so nobody can read it in transit. Think of sending your letter in a locked box.
Credential
A stored username and password, or token, that Jenkins uses to prove to the mail server that it is allowed to send.
Build status
The outcome of a build: success, failure, unstable (finished but some tests failed), or aborted (stopped early).
Trigger
In the extended email plugin, a rule that says “send an email when this situation happens”, such as a failure or a fix.
Recipient
A person or address that receives the email. Jenkins can compute recipients from the build itself.
Culprit
A person whose code change went in since the last good build, and who may have caused a failure. The word is not an accusation, only a hint about who to ask first.
Token
A placeholder such as the project name or build number that Jenkins swaps for the real value when it writes the email.
Plugin
An add-on that teaches Jenkins a new skill. Email features come from plugins.
Post section
In a pipeline, the part that runs after the stages finish. It is the natural home for notification actions.
4Architecture and Components
Several pieces work together to turn a finished build into an email in someone’s inbox.
A Jenkins system has one controller, the brain, and many agents, the workers. Builds run on agents, but the emails are sent by the controller. The controller holds the mail settings, the stored credentials, and the plugins. When a build finishes, the controller checks the notification rules, builds the message, and hands it to the mail server.
flowchart LR
AGT["Build Agent"] -->|"build result"| CTRL["Jenkins Controller"]
CTRL --- MAILPLUG["Mailer and Email Extension Plugins"]
CTRL --- CRED[("Credentials Store")]
CTRL --- SETTINGS[("Global Mail Settings")]
MAILPLUG -->|"compose message"| MSG["Email Message"]
MSG -->|"SMTP over TLS"| SMTP["SMTP Mail Server"]
SMTP --> INBOX1["Developer Inbox"]
SMTP --> INBOX2["Team Mailing List"]
SMTP --> INBOX3["Manager Inbox"]
CTRL -->|"link to logs"| UI["Build Page in Jenkins"]
INBOX1 -->|"click link"| UI
Walking through the picture
The build agent finishes its work and reports the result to the controller. The controller looks at its mail plugins and their rules. If a rule matches, the plugin composes a message using the result, the project name, and the list of changes. The controller fetches the mail server login from the credentials store, connects to the SMTP mail server, and hands the message over. The mail server delivers it to the inboxes of the chosen people. Inside the message is a link back to the build page in Jenkins, so a click takes the reader straight to the log.
The two main plugins
Two plugins do most of the work, and it helps to know the difference.
| Question | Mailer (basic) | Email Extension (extended) |
|---|---|---|
| How simple is it? | Very simple: a few switches | Rich: many triggers, recipients, and templates |
| When does it send? | On failure, on unstable, and when a broken build is fixed | Whenever you define: always, failure, fixed, still failing, success, and more |
| Who receives it? | A fixed list, plus optional emails to those who broke the build | Developers, requester, culprits, committers, suspects, and lists |
| Can I edit the message? | No, the text is fixed | Yes, subject and body can be customized, including HTML |
| Can it attach the log? | No | Yes |
| Best for | Small teams and quick setup | Real teams that want control |
The two plugins are configured in different places and have different settings. The extended plugin uses the same mail server details as the basic one in many setups, but it has its own section for defaults, so check both.
5Setting Up the Mail Connection
Before Jenkins can send anything, it must be told which mail server to use. This is a one-time setup for the whole Jenkins system.
Open the system settings
An administrator opens Manage Jenkins, then the System page. This is where global settings live.
Set the Jenkins URL
In the Jenkins Location section, make sure the Jenkins URL is the real web address people use. Emails use it to build links. If it is wrong, every link in every email will be broken.
Set the system administrator address
This is the “from” address that appears on the emails. Choose an address that your mail server accepts as a sender.
Enter the SMTP server details
In the E-mail Notification section, give the server name, the port, whether to use SSL or TLS, and the login if the server requires one.
Send a test email
Jenkins has a test button that sends a sample message to an address you type. If the test works, the connection is good.
Configure the extended plugin
If you use it, fill in its own section with default recipients, default content, and default triggers, so jobs need less setup.
Understanding the ports
Submission with STARTTLS
The modern, recommended door for sending mail from applications. The connection begins plain and is then upgraded to a secure one.
Secure from the start
The connection is encrypted with SSL from the very first moment. Widely used and fully supported.
Server-to-server mail
The traditional door between mail servers. Many networks block it for ordinary applications, and it often lacks encryption. Use it only inside a trusted internal network, if your mail team says so.
Logging in to the mail server
Most mail servers ask senders to prove who they are. Jenkins stores the username and password, or better a limited token, in its credentials store, a safe box that keeps secrets encrypted. You choose the credential by name in the mail settings. Many providers today no longer accept a person’s ordinary password for automation. They expect a special app password, an API key, or a modern login method. Ask your mail team which one your provider wants.
Never use a real person’s personal mailbox login for Jenkins. When that person leaves or changes their password, all notifications silently stop. Use a dedicated service mailbox or a sending service.
Setting up the mail connection is like giving the school office a post office account. You must give the post office’s address, the door to use, and a proof of identity. Only then will the post office accept the letters. The test email is the first practice letter.
6Basic Email Notification with the Mailer
The simplest way to get started is the basic post-build action called “E-mail Notification”.
In a classic job, you scroll to the Post-build Actions section and add “E-mail Notification”. You type one or more email addresses, separated by spaces. That is almost all there is to it. There is also a checkbox, “Send separate e-mails to individuals who broke the build”, which lets Jenkins guess the developers whose changes caused trouble and email them too.
What the basic mailer does automatically
- Emails when a build fails. The listed people are told a build broke.
- Emails when a build becomes unstable. Tests failed, but the build itself finished.
- Emails when a broken build is fixed. A “back to normal” message tells everyone the trouble is over.
- Stays quiet while it keeps failing. Jenkins does not repeat the same alarm on every failed build. It mainly speaks when the state changes.
This “speak only on change” behavior is a good default, because it avoids flooding inboxes. The trade-off is that you cannot easily ask for an email after every successful build, or attach the log, or change the wording. For that, you need the extended plugin.
Notification from a pipeline
In a pipeline job, there is a step named mail that sends a basic message. You give it recipients, a subject, and a body. It is normally placed in the post section, so it runs after the stages finish, and it can be tied to a condition, such as “only when the build fails”. The message text is written by you, so it can include the project name and a link.
Upsides of the basic mailer
- Extremely quick to set up
- Sensible default: speaks mostly on changes
- Little to learn and little to break
Downsides
- Fixed message wording
- No log attachment
- Limited choice of when and to whom
- Guessing who broke the build can be imperfect
7Extended Email Notification with Email Extension
When the basic mailer feels too small, the Email Extension plugin, often called Email-ext, offers full control.
In a classic job it appears as “Editable Email Notification”. In a pipeline it is available through a step named emailext. Either way, you get four big controls: who receives the message, when it is sent, what it says, and extras such as attachments.
The parts of an extended notification
Project recipient list
The default addresses for this job, for example a team mailing list.
Content type
Plain text, HTML, or both. HTML lets you use colors, tables, and buttons for a friendlier look.
Default subject and body
The wording of the message, written with tokens that Jenkins fills in for each build.
Attachments
You can attach the build log, or files produced by the build, such as a test report.
Triggers
The rules for when to send. Each trigger picks its own recipients and can override the message.
Triggers: choosing the moment
Always
Sends after every build, no matter what. Good for a small nightly job that people expect a report from, noisy for busy jobs.
Failure
Sends whenever a build fails. Simple, but repeated failures create repeated emails.
Failure, first only
Sends only for the first failure after a good run. Avoids repeating the same alarm.
Still failing
Sends a reminder when the build keeps failing across several runs, so a problem is not forgotten.
Fixed
Sends when a broken build becomes healthy again, closing the story.
Success
Sends after each successful build. Useful for releases, too noisy for frequent builds.
Unstable
Sends when the build finished but some tests failed.
Status changed
Sends when the result differs from the previous build, in either direction.
Slow build alerts
Some setups can alert when a build takes far longer than usual, an early hint of hidden trouble.
Recipient providers: choosing the people
The extended plugin can work out recipients from the build itself. These automatic recipient choices are called recipient providers.
| Provider | Who it picks | Best used for |
|---|---|---|
| Developers | Everyone who committed changes in the builds since the last good one | Failure alerts to the likely responsible people |
| Culprits | People who changed code since the last successful build | Similar to developers, focused on the failure window |
| Requester | The person who manually started the build | Manual jobs such as release buttons |
| Committers or suspects | Authors of the changes or people linked to failing tests | Narrowing alerts to the most relevant person |
| Fixed list | Addresses you type in | Team mailing lists and managers |
| Upstream committers | People who changed code in projects this job depends on | Chains of connected jobs |
A well-tuned combination is: failures go to the developers who changed code plus the team list, and “fixed” messages go only to the team list. The person who broke it gets an alarm, and everyone gets the all-clear.
Tokens: writing messages that fill themselves in
A token is a placeholder such as the project name, the build number, the build status, or the link to the build page. When Jenkins sends the message, it swaps each token for the real value. This lets you write one message template for many builds. Other tokens can add the list of changes, the last lines of the console log, the test results summary, or the duration. Use them to make messages that answer the reader’s first questions without needing another click.
Think of a form letter that says “Dear NAME, your parcel NUMBER has arrived”. The post office prints one template and fills in the name and number for each customer. Tokens are the NAME and NUMBER blanks in your Jenkins email.
8How Jenkins Sends an Email Internally
Let us follow one notification from the moment a build ends to the moment the message reaches an inbox.
The build finishes
The agent reports the result, and the controller records the build status and the list of changes.
Post actions begin
Jenkins runs the post-build actions or the pipeline post section, including the email step.
Rules are checked
The plugin compares the result with its triggers. If no trigger matches, no email is sent and nothing more happens.
Recipients are worked out
The plugin combines the fixed list with automatic providers such as developers, and removes duplicates.
The message is composed
Tokens are replaced with real values, attachments are added, and the subject and body are finalized.
The connection is opened
The controller connects to the SMTP server on the chosen port, upgrades to a secure connection, and logs in with the stored credential.
The mail server takes over
The server accepts the message and delivers it onward. From here, delivery speed and spam checks are the mail system’s business.
sequenceDiagram participant B as Build Agent participant C as Jenkins Controller participant P as Email Plugin participant S as SMTP Server participant R as Recipient Inbox B->>C: Build finished with result C->>P: Run post-build email action P->>P: Check triggers and choose recipients P->>P: Fill tokens and build message P->>S: Connect securely and log in S-->>P: Accept message S->>R: Deliver email R-->>R: Reader clicks link to build page
Why the controller sends the mail
Emails are sent by the controller, not by the agent that ran the build. That means the controller must be able to reach the mail server over the network. If your Jenkins runs in a locked-down network, the mail server must be reachable from the controller, and the firewall must allow the chosen port. Agents do not need mail access at all, which is another reason to keep secrets and mail settings on the controller only.
What happens if sending fails
If the mail server is unreachable or rejects the message, the email step usually reports an error in the build log, and depending on settings, the build may still be marked successful, because failing to send a notification is not the same as failing to build. Jenkins does not normally keep a retry queue, so a message lost during a mail server outage is simply lost. This is a reason not to rely on email alone for critical alarms.
9Designing Good Notifications
Sending an email is easy. Sending one that people read and act on is a craft.
A good subject line
The subject is often all that people read. A great subject says three things at a glance: the result, the project, and the build number. Something like “Failed: online-shop, build 482” tells the reader almost everything before opening the email. Put the status first so that inbox filters and human eyes can scan it quickly.
A good body
Result first
State success or failure in the first line, in plain words.
A clear link
One prominent link to the build page and one to the log, so the reader is one click away from the details.
What changed
The list of commits and authors since the last good build, which points to the likely cause.
What failed
A summary of failing tests, or the last lines of the log, so a quick diagnosis is possible.
Who is asked
Say who is expected to act. An email addressed to everyone is acted on by no one.
Short and calm
No shouting, no blame. A calm tone gets faster and friendlier fixes.
Fighting notification fatigue
Notification fatigue happens when people receive so many messages that they stop reading any of them. It is the number one reason email alerts fail in practice. Avoid it with these habits.
- Prefer state changes. Email when a build first breaks and when it is fixed, not on every repeated failure.
- Target the right people. Developers of the changed code should hear first; a manager may only need a daily summary.
- Do not notify on success for busy jobs. A green build every five minutes is not news.
- Use different channels for different urgency. Email for normal news, a chat message or pager for real emergencies.
- Review regularly. If an alert is always ignored, fix its cause or remove it.
Remember the boy who cried wolf. If every small rustle is announced as a wolf, the villagers stop coming. Alerts that fire too often teach people to ignore them, so the real wolf gets in.
Never put secrets, passwords, or private customer data into an email body or attachment. Emails are copied, forwarded, and stored in many places outside your control.
10Email in Pipelines
Modern Jenkins teams describe their pipeline in a text file called a Jenkinsfile. Email notification fits naturally into it.
A declarative pipeline has a post section that runs after the stages. Inside it you can list conditions such as “always”, “success”, “failure”, “unstable”, “changed”, “fixed”, “regression”, and “aborted”. Each condition can contain an email step. This gives you the same flexibility as extended triggers, but written as text that lives beside your code, where it is versioned and reviewed.
flowchart TD
ST["Pipeline Stages Finish"] --> POST{"Post Section"}
POST -->|"failure"| F["Email Developers and Team List"]
POST -->|"fixed"| X["Email Team: Back to Normal"]
POST -->|"unstable"| U["Email Testers"]
POST -->|"always"| CL["Clean Workspace"]
POST -->|"success"| OK["No email, or Release Notice Only"]
Useful post conditions for email
failure
The pipeline failed. Send an alert to the responsible people.
fixed
The pipeline is successful now, and the previous run was not. Send an all-clear.
changed
The result differs from the previous run. Useful for a single message covering both breaks and fixes.
regression
The result is worse than the previous run, for example from success to unstable or failure.
unstable
Tests failed but the build completed. Send a message to testers.
aborted
A person or a time limit stopped the run. Worth telling the owner if unexpected.
Emails from inside a stage
Emails do not have to wait until the end. A stage can send a message of its own, for example asking a person to approve a release before the pipeline continues. Such approval emails should always include a clear link to the waiting pipeline and should say what will happen if nobody answers.
Shared libraries for consistent messages
If fifty projects each write their own email text, messages will look different and mistakes will be repeated. Teams often put the notification logic into a shared library, a central collection of reusable pipeline pieces. Every project calls the same “notify” routine, so a wording improvement reaches everyone at once.
11Data Flow and the Notification Lifecycle
Here is the whole story from code change to a reader acting on an email.
flowchart LR
A["Developer Pushes Code"] --> B["Jenkins Builds and Tests"]
B --> C{"Result"}
C -->|"success"| D["Optional Success Notice"]
C -->|"failure"| E["Failure Email to Developers and Team"]
E --> F["Developer Opens Build Link"]
F --> G["Developer Fixes and Pushes"]
G --> B
C -->|"fixed after failure"| H["All-Clear Email to Team"]
The link between email and the build page
An email is a doorway, not a warehouse. It should give a short summary and then send the reader to Jenkins for the details. That is why the Jenkins URL setting matters so much. If the URL points to an internal name that readers cannot reach from their phones, the links in the emails will be useless. Check that links work from where people actually read their mail.
Threading and inbox rules
Consistent subject lines let mail programs group messages and let people create filters, such as “put all emails from Jenkins about the payment project into one folder”. Consistency is a quiet but powerful feature. Avoid putting random numbers or changing words into subjects unless they carry real meaning.
12Security in Email Notification
Email seems harmless, but the mail connection touches secrets, and messages can leak information.
Protect the mail login
- Use the credentials store. Never type the mail password in a text box that anyone can read.
- Use a dedicated sender account with permission only to send mail, not to read mailboxes.
- Use app passwords or tokens where the provider requires them, and rotate them on a schedule.
- Restrict who can change global mail settings. Only administrators should edit them.
Encrypt the connection
Always use SSL or TLS between Jenkins and the mail server, so nobody on the network can read the login or the message. Avoid plain unencrypted connections, except inside a trusted private network approved by your mail team.
Mind the content
Build logs sometimes contain sensitive details, such as server names, internal paths, or accidentally printed keys. Attaching full logs to emails copies those details into many inboxes. Prefer a link to the log inside Jenkins, where access can be controlled, and limit attachments to what is truly needed.
Be careful with templates and scripts
The extended plugin can run small scripts to decide recipients or tweak the message. Scripts are powerful, so restrict who may write them, and use the plugin’s safety sandbox where available. A careless script can leak data or send mail to unintended people.
Avoid becoming a spam source
If a job sends emails to a huge list, or loops and sends thousands of messages, your mail server may be blocked by the provider. Set sensible limits, avoid triggering emails from builds that run every minute, and make sure only trusted people can edit notification lists.
Anyone who can edit a job’s email settings can direct build details to any address. Treat notification settings as sensitive, especially for projects with private code.
13Deliverability: Making Sure Emails Arrive
A message can leave Jenkins perfectly and still never reach the inbox. Understanding why saves hours of confusion.
Receiving mail systems are suspicious by nature, because most email in the world is spam. They check whether a message really comes from the sender it claims. Three common checks are worth knowing, in simple words.
Sender Policy Framework
A public list saying which servers may send mail for your domain. If Jenkins sends through a server not on the list, receivers may distrust the message.
Digital signature
The sending server signs each message, and receivers check the signature against a public key. It proves the message was not altered.
Policy on top
Tells receivers what to do when SPF or DKIM checks fail, such as put the message in spam or reject it.
If your “from” address uses your company domain, but Jenkins sends through a server that your domain does not authorize, messages may be sent to spam or rejected outright. The simplest fix is to send through your company’s official mail system or an approved sending service, and to use a “from” address that this system is allowed to send for.
Common delivery symptoms
| Symptom | Likely cause | What to check |
|---|---|---|
| Test email fails with a login error | Wrong username, password, or login method | Credential, app password requirement, and account permissions |
| Test email fails to connect | Wrong server name, wrong port, or a firewall block | Server address, port, and network access from the controller |
| Secure connection error | Mismatch between SSL and TLS settings and the port | Whether the port expects SSL from the start or STARTTLS |
| Message is rejected for the sender | The “from” address is not allowed for this login | Sender rules on the mail server |
| Emails land in spam | Failing SPF, DKIM, or DMARC, or a spammy subject | Domain email authentication and message wording |
| Links in the email are broken | Wrong Jenkins URL setting | The Jenkins Location settings |
| Some people never get emails | Addresses missing, mailing list rules, or developers’ emails unknown to Jenkins | Recipient list and how Jenkins maps committers to addresses |
| Developer alerts go to nobody | Jenkins cannot turn a committer name into an email address | User email settings in Jenkins, or a default email domain setting |
When emails go missing, work from the outside in. First, does the Jenkins test email arrive? Then, does the build log show an email step? Then, do the mail server logs show the message accepted? Then, is it in a spam folder? Each step narrows the search.
14Monitoring, Logging, and Troubleshooting
Watch the notification system itself, because a silent alarm is the most dangerous kind.
Where to look for clues
Every build has a console output, a running diary of everything the build did. When an email step runs, the console shows whether it sent a message and to whom, or whether it hit an error. Jenkins also has a system log that records events from plugins, including mail problems. The mail server keeps its own logs showing which messages it accepted and where it sent them. Together, these three answer the question, “Did the message leave Jenkins, and did it arrive?”
Health checks to run regularly
Send a test email
After any change to the mail settings or the network, use the test button. A working test is the fastest health check.
Credential expiry
App passwords and tokens can expire. A quiet expiry means notifications stop without any warning.
Email volume
A sudden jump in emails may mean a loop or a failing job spamming inboxes. A sudden drop may mean a broken setting.
Send failures
Count how often the email step reports errors. Rising failures suggest mail server or network trouble.
Many teams also add a small heartbeat: a scheduled job that sends one harmless email to a monitoring address each day. If the heartbeat stops arriving, someone knows the notification path is broken, even when no build has failed.
Pressing the test button on a smoke alarm once a month proves it still works. A daily heartbeat email is the same idea: a small regular check that the alarm can still ring when it needs to.
15Email Compared with Other Notification Channels
Email is not the only messenger. Choosing the right channel for the right message makes teams calmer.
| Channel | Strengths | Weaknesses | Best for |
|---|---|---|---|
| Universal, searchable, works for people outside the team, good record | Slow to notice, easy to ignore, spam filters, no live conversation | Normal build results, reports, and audit trails | |
| Chat messages | Fast, visible to the whole team, lively discussion | Messages scroll away, needs a chat tool | Team alerts and quick coordination |
| Pager or on-call alerts | Wakes a person up, hard to miss | Intrusive, costly, must be used sparingly | Real emergencies in production |
| Status marks on pull requests | Appears exactly where the reviewer is looking | Only for code review moments | Telling reviewers whether a change is safe |
| Dashboards and wall screens | Constant visibility for the team | Passive, nobody is told when to look | Team awareness of overall health |
A practical mix is to use email for a durable record and for people outside the team, a chat message for quick team awareness, and a pager only for real production emergencies. Jenkins can send to all of these through plugins, sometimes from the same pipeline step.
16Advantages, Disadvantages, and Trade-offs
Every choice has a price. Knowing both sides helps you design notifications wisely.
Advantages of email notification
- Works for everyone, even people who never open Jenkins
- Leaves a searchable record in inboxes
- Easy to set up with the basic mailer
- Highly customizable with the extended plugin
- Can carry summaries, links, and attachments
- No extra chat or pager tool needed
Disadvantages and costs
- Easy to ignore, and notification fatigue is common
- Delivery depends on mail servers and spam filters
- Mail credentials must be stored and rotated
- No built-in retry, so an outage can lose messages
- Slow compared with chat or pager for urgent issues
- Logs attached to emails may leak sensitive details
Choosing between the two plugins
| Situation | Better choice | Why |
|---|---|---|
| Tiny team, few jobs, quick start | Basic mailer | Almost no setup and sensible defaults |
| Need custom wording or HTML | Email Extension | Editable subject and body |
| Need to email the right developers only | Email Extension | Recipient providers work out who changed the code |
| Want an all-clear message | Either; extended offers more control | Both can report a fix; extended lets you tune it |
| Pipeline written as text | The pipeline email steps | The rules live in the Jenkinsfile beside the code |
| Dozens of projects needing the same look | Shared library on top of Email Extension | One place to improve messages for everyone |
17Design Patterns and Anti-Patterns
A pattern is a proven habit. An anti-pattern is a tempting shortcut that usually hurts later.
Patterns that work
Notify on state change
Send an email when a build first breaks and when it is fixed. Skip the repeats in between, or send only an occasional reminder.
Target the responsible people
Send failure alerts to the developers who changed the code, with the team list on copy, so the right person acts first.
A summary, then a link
Keep the email short: result, cause hints, and a link. Let Jenkins hold the details.
Service mailbox
Send from a dedicated automation address so notifications survive staff changes.
Shared notification library
Put email logic in a shared library so all projects look and behave alike, and fixes reach everyone together.
Escalation by urgency
Email for normal alerts, chat for team awareness, and a pager only when production is at risk.
Heartbeat check
Send a small daily email so a silent failure of the mail path is noticed quickly.
Anti-patterns to avoid
The pattern
Emailing the whole company after every single build, success or failure.
Why it hurts
People quickly create filters that hide every Jenkins email, and real failures get buried with the noise.
The better way
Email only on meaningful changes, and only to the people who can act.
The pattern
Using one person’s private mailbox login as the Jenkins mail account.
Why it hurts
When that person leaves or changes their password, all notifications stop silently, and nobody notices until a failure goes unseen.
The better way
Use a dedicated service mailbox or sending service with its own limited credential in the credentials store.
The pattern
Attaching the entire build log to every email.
Why it hurts
Big attachments clog inboxes and copy possibly sensitive details to many places outside Jenkins’ access control.
The better way
Include a link to the log and the last few relevant lines, and attach files only when truly needed.
The pattern
Never testing the mail settings after changes, and never checking that alerts still arrive.
Why it hurts
An expired credential or a changed firewall rule can turn off notifications without any warning.
The better way
Use the test button after each change, and add a daily heartbeat message.
The pattern
Relying on email alone for critical production emergencies.
Why it hurts
Email can be delayed, filtered, or unread for hours. Without a retry queue, a mail outage can lose the message altogether.
The better way
Use an on-call alerting tool for emergencies, and keep email as the durable record.
18Best Practices and Common Mistakes
These habits separate a helpful notification system from an annoying one.
Best practices
- Set the Jenkins URL correctly so every link in every email works from where people read it.
- Use a dedicated sender account and store its credential in the credentials store.
- Encrypt the connection with SSL or TLS, and pick the port that matches your security setting.
- Test the connection with the built-in test email after every change.
- Notify on state changes, and add occasional reminders for long-lasting failures.
- Send failures to the developers who changed the code, with the team on copy.
- Write clear subjects that start with the result, then the project, then the build number.
- Keep bodies short, with a link, changes, and a failure summary.
- Prefer links to attachments, and never include secrets in email content.
- Keep notification rules in the Jenkinsfile or a shared library, so they are versioned and reviewed.
- Configure authentication for your domain so receivers trust the messages, meaning SPF, DKIM, and DMARC.
- Add a heartbeat so a silent failure of the mail path is noticed.
- Review alerts regularly, and remove or fix any that people always ignore.
- Use several channels matched to urgency, with email as the durable record.
Common mistakes
Wrong Jenkins URL
Links point to localhost or an internal name that readers cannot open. Fix the URL setting first.
Port and security mismatch
Choosing an SSL setting that does not match the port causes confusing connection errors.
Unknown developer addresses
Jenkins knows committers only by name, not by email. Without a mapping or default domain, developer alerts go nowhere.
Too many triggers
Adding “always”, “failure”, and “still failing” together sends duplicates. Choose a clean set.
Notifying on the failing mail step
If the email step itself fails, and nobody checks, no one learns. Watch the build log for send errors.
Forgetting credential expiry
Tokens silently expire, and alerts stop. Track expiry dates and rotate on schedule.
Ask yourself before adding any email: “What should the reader do when they receive this?” If there is no answer, the email probably should not exist.
19Real-World Usage
Email notification shows up in almost every Jenkins installation. Here are common ways teams use it.
The broken build alert
When the main branch build fails, Jenkins emails the developers whose changes went in since the last good build, and copies the team list. The subject says failed, the project name, and the build number. The body links to the log and lists the commits. Most fixes start within minutes.
The all-clear message
When a broken build is fixed, a short “back to normal” email goes to the team list. This closes the loop, so nobody keeps wondering whether the trouble is over.
The nightly report
A scheduled job runs a long set of tests overnight and emails the results to the quality team at the start of the working day, with an attached report. Because it runs only once a day, the email is expected and read.
The release approval request
A pipeline pauses before deploying to production and emails a release manager with a link to approve or reject. The email states what will be released and when the request expires.
The unstable test summary
When tests fail but the build finishes, testers receive a summary of failing tests grouped by area, so they can decide quickly which to investigate first.
Compliance records
Regulated teams, such as banks, use email as a durable record of who was notified and when, alongside approval logs, so auditors can reconstruct events later.
Large engineering organizations
Companies running Jenkins at large scale, with thousands of pipelines, commonly move notification logic into shared libraries so every team sends consistent messages, and combine email with chat and on-call tools for different urgencies. Internet-scale companies such as Netflix have publicly described using Jenkins as part of their delivery flow alongside other tools.
A typical growth story
A small team begins with the basic mailer and a single team address. As the team grows, the emails become noisy, so they switch to the extended plugin and send failures only to the developers who changed the code. Next they move their rules into the Jenkinsfile and then into a shared library, so that every project looks the same. They add a heartbeat after a silent credential expiry costs them a missed failure. Finally they send emergencies to an on-call tool and keep email as the record. At each step the change was small, and the team never had to start over.
20Frequently Asked Questions
21Summary and Key Takeaways
You started with a smoke alarm in a kitchen and finished with a full picture of how Jenkins taps people on the shoulder when their builds need attention.
Key Takeaways
- Email notification lets Jenkins tell people about build results. The controller composes the message and hands it to an SMTP mail server for delivery.
- Two plugins do the work. The basic Mailer is simple and quiet by default, while Email Extension adds custom messages, triggers, recipient providers, and attachments.
- Set up the connection carefully. Use the right server, port, and encryption, a dedicated sender account, a correct Jenkins URL, and the test button after every change.
- Design for people, not for machines. Notify on state changes, send to those who can act, write clear subjects, and keep the body short with a link to Jenkins.
- Fight notification fatigue. Too many emails teach people to ignore all of them, so review and prune alerts regularly.
- Guard secrets and deliverability. Keep credentials in the credentials store, avoid secrets in message content, and set up SPF, DKIM, and DMARC so messages reach inboxes.
- Do not rely on email alone. Use a heartbeat to detect silent failures, chat for team awareness, and on-call alerts for real emergencies, with email as the durable record.