Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Fail2ban sends an email only when two separate pieces are working: a jail must invoke an email-capable action, and a mail-transfer agent (MTA) must actually submit the message. Configure both in a local override such as /etc/fail2ban/jail.local or a file in /etc/fail2ban/jail.d/, then verify the jail, log backend, and MTA independently.

The practical setup is to set destemail, sender, and mta, choose %(action_mw)s or %(action_mwl)s, enable the intended jail, and restart Fail2ban. The first action includes a Whois report; the second also includes matching log lines.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What Fail2ban email notifications require

A ban notification is an action executed by a Fail2ban jail. The action can call a local sendmail-compatible command, but Fail2ban is not itself a complete mail-delivery system. Ubuntu’s Fail2ban guidance states that you need sendmail or another MTA for this purpose.

The notification path therefore has four checkpoints:

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
  • The jail is enabled and its filter recognizes the service’s failed requests.
  • The jail reads the right log source through a compatible backend.
  • The jail’s action is an email action rather than a ban-only action.
  • An MTA accepts the message and can relay it to the destination mailbox.

If any checkpoint fails, an address may still be banned while no email appears. Treat detection, banning, message submission, and final delivery as separate systems during setup and troubleshooting.

Choose the right email action

Fail2ban’s upstream action definitions distinguish the two commonly used email actions by the information attached to the ban notice.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Setting What it does Use it when
%(action_mw)s Bans the address and emails the destination with a Whois report. You want a compact alert with ownership information about the source address.
%(action_mwl)s Bans the address and emails the destination with a Whois report plus relevant matching log lines. You need the evidence that caused the ban in the same message.
%(action_)s Performs the ban action without the email additions. Use only when email is intentionally disabled.

For most administrators, action_mwl is the more useful diagnostic choice because the message includes the matching log lines. On a busy host, those excerpts can make alerts larger and more frequent, so action_mw may be preferable when you only need a concise warning. Neither choice changes the ban threshold; they change the notification payload.

The action name is an interpolation variable, not a command you type at a shell prompt. A jail-specific action can override the global default, so inspect the effective jail configuration instead of assuming the value in [DEFAULT] is being used.

Install Fail2ban and an MTA

Install Fail2ban using your distribution’s package manager, then install and configure an MTA that provides the mail command expected by the selected action. The exact package name and relay configuration vary by distribution and hosting environment.

Before involving Fail2ban, confirm that the MTA can deliver a message on its own. A successful Fail2ban action means the command ran; it does not prove that the recipient’s mail server accepted, filtered, or delivered the message.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Know which local binary the action will call (the default examples use sendmail).
  • Set a sender address that your relay policy permits.
  • Configure DNS, authentication, or an upstream relay as required by your MTA.
  • Check the MTA’s own queue and logs when a test message does not arrive.

An MTA may accept a message locally and defer it because of a DNS, authentication, recipient, or relay-policy problem. That is why a mailbox check alone is not enough: correlate the Fail2ban log with the MTA queue and delivery log.

Keep local settings separate from vendor defaults

Do not edit the packaged jail.conf directly. Package upgrades can replace it. A simple local-copy approach is:

sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudoedit /etc/fail2ban/jail.local

When your distribution supports it, a dedicated file under /etc/fail2ban/jail.d/ is easier to maintain because it contains only your changes. Fail2ban’s manpage documents local overrides for jail and action configuration. Use the same principle for custom action settings: place local changes in the appropriate local action file rather than modifying a vendor file.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

A small override also makes upgrades and audits safer. Keep comments explaining why a non-default threshold, sender, or ignored address exists. If several services need different recipients or actions, define those values in each jail rather than making a global setting unexpectedly broad.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure global notification values

Add or override the notification variables in the [DEFAULT] section of your local configuration:

[DEFAULT]
destemail = admin@example.com
sender = fail2ban@example.com
mta = sendmail
action = %(action_mwl)s

destemail

This is the mailbox that receives ban notices. Use an address monitored by the people responsible for the server. If you have separate addresses for security alerts and routine administration, choose deliberately; Fail2ban will use the value applied by the relevant jail. A shared security mailbox or ticketing address can be more resilient than one person’s account, provided its filtering rules preserve the alerts.

sender

This is the envelope or header sender supplied to the action. It must be acceptable to your MTA and any relay policy. A syntactically valid address alone does not guarantee acceptance: the relay may require authentication, a permitted domain, or DNS alignment. Use a sender identity that your organization can monitor for bounces and that the configured relay is authorized to use.

mta

Set this to the mail transport interface your action expects. The example uses sendmail; if you select another supported transport, make sure the corresponding command exists and works independently. Installing an MTA package without configuring its submission command, queue, or relay does not complete this step.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

action

Set this to %(action_mw)s for a Whois report or %(action_mwl)s for a Whois report and relevant log lines. If the value remains %(action_)s, Fail2ban can ban addresses without sending mail. Check every enabled jail for an explicit action that might supersede this global value.

Enable and tune a jail

The following example enables the SSH jail. Adapt the filter and log source to the service and operating system on your host:

[sshd]
enabled = true
port = ssh
filter = sshd
logpath = %(sshd_log)s
maxretry = 5
findtime = 10m
bantime = 1h

The section name identifies the jail, while filter selects the pattern that recognizes failures. The port value must describe the actual exposed service; using the symbolic value ssh is convenient only when the host’s service mapping is correct. Likewise, %(sshd_log)s must resolve to a real log source on the distribution.

Understand the three thresholds

Option Meaning Effect of changing it
maxretry Number of failures required before a ban. Lower values alert and ban sooner, but are more sensitive to mistakes or noisy clients.
findtime Interval during which failures are counted. A shorter interval focuses on bursts; a longer interval catches slower repeated attempts.
bantime How long the address remains banned. Longer bans reduce repeated attempts but increase the impact of a mistaken ban.

These values control when an email action runs. Tune them for the service’s normal traffic and threat level rather than copying values blindly. Alert volume is a security-policy decision as much as a mail setting. A public SSH service with constant scanning may need a different balance from an internal application used by a small group of people.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Remember that one source can produce repeated bans as its ban expires and new failures meet the threshold. If the resulting mail volume is excessive, review the policy and thresholds rather than assuming the MTA is duplicating messages.

Match the log backend to the host

A jail cannot trigger if its filter is watching the wrong source. Fail2ban documents the systemd, polling, pyinotify, and auto backends.

Services logging to the systemd journal

Use a journal-oriented configuration when the service writes only to the systemd journal. The jail must have a suitable journal match rather than a file path that does not exist. In that situation, verify the service’s journal entries and configure the jail’s journal-related option accordingly. A valid filter pointed at an empty or unrelated file will never reach maxretry.

Services writing traditional log files

Use a file-monitoring backend and a valid logpath when the service writes to files. Confirm the path, permissions, rotation behavior, and the format of the entries before testing a filter. Rotation can move the file the jail was watching, and restrictive permissions can prevent Fail2ban from reading it even though the service itself continues to log.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Automatic and polling choices

auto lets Fail2ban select an available backend; polling and pyinotify monitor files in different ways. The correct choice depends on what your distribution provides and how the service emits logs. A backend mismatch can leave Fail2ban running normally while the jail sees no failures. Confirm the selected backend in the effective configuration and compare it with the host’s actual logging architecture.

Apply the configuration and inspect the parsed result

After saving the local override, restart Fail2ban using the service manager supplied by your distribution:

sudo systemctl restart fail2ban
sudo fail2ban-client status
sudo fail2ban-client status sshd

The general status should list the enabled jail. The jail-specific status should show its filter and current counters. If Fail2ban refuses to start, inspect interpolation and quoting first. You can dump the parsed configuration before restarting:

sudo fail2ban-client -d

Review the dump for the effective destemail, sender, mta, action, backend, log source, and threshold values. This catches a misspelled section, an override loaded in an unexpected order, or an interpolation value that was not expanded as intended. It is especially useful when a package supplies multiple files under jail.d and you are unsure which value wins.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Restarting applies changes to the daemon, but it does not retroactively process every old log entry as a new event. Test with a fresh, controlled event after the new configuration is active.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Verify a notification without locking yourself out

Testing should prove both that a jail detects a failure and that the MTA delivers the resulting message. Do not generate a test attack from an address you may need for administration unless you have a separate, confirmed access path.

  1. Confirm that the test source is in an approved, controlled range and that your administrative address is protected by the jail’s ignoreip policy where appropriate.
  2. Check the jail status and its filter/log source before creating a test event.
  3. Generate a controlled failed authentication event for the selected service, staying below any lockout risk for your own account and access path.
  4. When the threshold is reached, inspect the Fail2ban log for the ban and action execution.
  5. Inspect the MTA log and queue at the same time. A Fail2ban action message indicates invocation, not final mailbox delivery.
  6. Check the destination mailbox, quarantine, and spam folders, then trace any rejection or relay error in the MTA logs.

Testing the MTA separately is important. Send a test message through the same transport and sender identity without Fail2ban. If that fails, changing a jail filter cannot fix delivery. Conversely, a successful standalone message does not prove that the selected action is enabled, so test both paths.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot missing or incorrect alerts

No email action appears in the logs

Inspect the effective jail configuration and confirm that its action is %(action_mw)s or %(action_mwl)s. A ban-only %(action_)s action explains why addresses are blocked while no email command runs. Also check whether a jail-specific action overrides the global value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The jail never triggers

Check all four parts together: enabled, filter, the logpath or journal match, and the backend. Read a real log entry and compare its timestamp, program name, address format, and failure text with what the filter expects. A syntactically valid configuration can still watch an empty file or the wrong journal.

Fail2ban starts but rejects the file

Use fail2ban-client -d to expose the parsed configuration. Look for malformed interpolation, unmatched quotes, invalid section placement, and values that were overridden later in the load order. Correct the local file, dump it again, and restart only after the effective values are coherent.

The mail command fails

Verify that the binary named by the action exists and that the MTA can deliver a test message independently. Then check the MTA’s queue, authentication, relay permissions, DNS requirements, and sender policy. Fail2ban cannot repair a rejected relay or a message held by the MTA. If the command is present but returns an error, run the equivalent test with the same sender and destination to isolate the transport.

The wrong address is banned

Review ignoreip and the way hostnames are resolved. Fail2ban’s manpage warns that reverse and forward DNS can disagree; relying on a hostname that resolves differently in each direction can produce an unexpected exemption or ban. Prefer carefully controlled addresses or networks for critical administrative access. Confirm that trusted monitoring systems, bastion hosts, and recovery paths are covered without broadly exempting untrusted networks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There are too many or too few alerts

Adjust maxretry, findtime, and bantime together. If normal users frequently mistype credentials, increase the failure tolerance or shorten the observation window. If slow, distributed attempts evade the current threshold, use a longer findtime or a more appropriate service-specific policy. Changing from action_mwl to action_mw reduces message detail, not the number of bans.

The message arrives without useful evidence

Check whether the jail uses action_mw, which intentionally includes only the Whois report, or action_mwl, which adds relevant matching log lines. Also verify that the jail can read the log source; unavailable or unreadable logs leave the action with less evidence to include.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Use an external notification service instead of email

Fail2ban’s upstream configuration also documents Apprise actions for external notification services. This route requires separate Apprise configuration and credentials for the service you select. It is an alternative notification path; it does not replace a functioning MTA when the jail uses action_mw or action_mwl. The project configuration describes support for more than 120 services through Apprise, although the available integrations can change with releases.

Choose the path based on the operational requirement:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Requirement Suitable approach Important dependency
Mailbox alert with ownership data action_mw Working MTA and relay policy.
Mailbox alert with ownership data and evidence action_mwl Working MTA, plus access to the relevant log lines.
Notification through an external service Apprise action Apprise configuration, credentials, and service availability.

External delivery changes the dependency chain, not the need for careful testing. Protect service credentials, verify that the destination is reachable, and confirm that a notification is generated only for the intended jail events.

Operational checklist

  • Install Fail2ban and an MTA before expecting email.
  • Keep package defaults untouched; use jail.local, jail.d, or local action overrides.
  • Set destemail, sender, and the correct mta.
  • Select action_mw or action_mwl, not the ban-only action.
  • Enable the intended jail and set its filter, source, backend, and thresholds.
  • Use fail2ban-client -d when interpolation or load order is unclear.
  • Confirm jail status, Fail2ban logs, MTA logs, and mailbox delivery separately.
  • Protect administrative addresses with a deliberate ignoreip policy and a verified recovery path.
  • Test a standalone MTA message and then a controlled Fail2ban event.
  • Recheck local overrides after package upgrades and review any changed vendor action definitions.

Frequently Asked Questions

How do I make Fail2ban email me when an IP is banned?

Install and configure an MTA, then set destemail, sender, and mta in a local Fail2ban override. Set the jail’s action to %(action_mw)s or %(action_mwl)s, enable the jail, restart Fail2ban, and verify both the Fail2ban and MTA logs.

What is the difference between action_mw and action_mwl?

action_mw bans the address and sends a Whois report. action_mwl sends the same Whois report plus relevant matching log lines, making it better for investigation but potentially producing larger alerts.

Why does Fail2ban ban addresses but send no email?

The jail may be using the ban-only %(action_)s action, or a jail-specific setting may override the global email action. If the email action runs but no message arrives, test the MTA separately and inspect its queue, relay policy, DNS, sender permissions, and spam or quarantine handling.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do I need an MTA for Fail2ban email notifications?

Yes. Ubuntu’s Fail2ban guidance explicitly says that sendmail or another MTA is required. Fail2ban invokes the configured mail command; it does not guarantee acceptance or final delivery to the mailbox.

Should I edit jail.conf directly?

No. Keep vendor defaults intact and place changes in /etc/fail2ban/jail.local, a file under /etc/fail2ban/jail.d/, or an appropriate local action file. This prevents package updates from overwriting your settings and makes the effective configuration easier to audit.

Why is my jail enabled but never triggering?

Check the filter, the actual log source, and the backend together. Use a journal-oriented configuration for services that log only to systemd, or a file-monitoring backend with a valid logpath for traditional log files. Compare a real failure entry with the filter’s expected format.

How can I test without locking myself out?

Use a controlled test source with a confirmed recovery path, protect administrative addresses with an intentional ignoreip policy, and inspect status before generating a fresh test event. Never test from your only remote administration address.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can Fail2ban send alerts through Apprise instead of email?

Yes. Upstream action definitions document Apprise integrations for external notification services. Configure the selected service and credentials separately. Apprise is an alternative path and does not remove the MTA requirement when using action_mw or action_mwl.

The Bottom Line

Reliable Fail2ban email alerts come from the combination of a correctly enabled jail, a matching log backend, an email action, and a functioning MTA. Use action_mw for a Whois-only notice or action_mwl when the alert should include matching log lines, then validate Fail2ban execution and mail delivery as separate systems.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.