diff --git a/logwatch-sendmail-id.patch b/logwatch-sendmail-id.patch
new file mode 100644
index 0000000..4a88ef5
--- /dev/null
+++ b/logwatch-sendmail-id.patch
@@ -0,0 +1,41 @@
+From ddbd80b1efaa6e95536d0262985f13147208e775 Mon Sep 17 00:00:00 2001
+From: Oleg Girko
+Date: Wed, 28 Mar 2018 15:43:12 +0100
+Subject: [PATCH] Fix pattern for sendmail queue ID to parse ones with PID
+ having 7 digits.
+
+Sendmail 8.15 uses the following format for queue id:
+- 6 letters or digits dependent on date and time,
+- 2 letters or digits dependent on random sequence ID,
+- PID of sendmail process formatted by snprintf using "%06d" format.
+
+Format "%06d" means that resulting string has *minimal* length of 6 characters,
+padded with leading zeroes if necessary.
+But if PID is greater than 999999, the resulting string can be longer,
+up to 7 characters if kernel.pid_max sysctl parameter is big enough.
+By default it's 32768, but can be up to 4194304 on 64-bit systems.
+
+This change fixes logwatch to parse sendmail log lines produced by
+sendmail processes that have 7-digit PID.
+
+Signed-off-by: Oleg Girko
+---
+ scripts/services/sendmail | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/scripts/services/sendmail b/scripts/services/sendmail
+index d97e7a2..1acd733 100644
+--- a/scripts/services/sendmail
++++ b/scripts/services/sendmail
+@@ -387,7 +387,7 @@ for my $i (0..9) {
+ }
+
+ # QueueID formats: in 8.11 it was \w{7}\d{5}, in 8.12+ it is \w{8}\d{6}
+-my $QueueIDFormat = "(?:\\w{7,9}\\d{5}|NOQUEUE)";
++my $QueueIDFormat = "(?:\\w{7,9}\\d{5,7}|NOQUEUE)";
+
+ # ENOENT refers to "no such file or directory"
+ my $ENOENT = Errno::ENOENT();
+--
+2.14.3
+
diff --git a/logwatch.spec b/logwatch.spec
index 84ecbf6..4920c23 100644
--- a/logwatch.spec
+++ b/logwatch.spec
@@ -1,7 +1,7 @@
Summary: A log file analysis program
Name: logwatch
Version: 7.4.3
-Release: 9%{?dist}
+Release: 10%{?dist}
License: MIT
Group: Applications/System
URL: http://www.logwatch.org/
@@ -21,6 +21,7 @@ Patch5: logwatch-journal.patch
# https://sourceforge.net/p/logwatch/git/ci/ed6eb62f40cb97f71f3df4d982682de68cdf1037/
Patch6: logwatch-journald-source.patch
Patch7: logwatch-sshd-2.patch
+Patch8: logwatch-sendmail-id.patch
BuildRequires: perl-generators
Requires: grep mailx
Requires: perl(Date::Manip)
@@ -45,6 +46,7 @@ of the package on many systems.
%patch5 -p1
%patch6 -p1
%patch7 -p1
+%patch8 -p1
rm -f scripts/services/*.orig
%build
@@ -144,6 +146,9 @@ echo "# Configuration overrides for specific logfiles/services may be placed her
%{_mandir}/man*/*
%changelog
+* Mon May 21 2018 Jan Synáček - 7.4.3-10
+- Fix parsing of log entries produced by sendmail process with 7-digit PID (#1561587)
+
* Fri Feb 09 2018 Igor Gnatenko - 7.4.3-9
- Escape macros in %%changelog