Partial fix Job XF:EmailUnsubscribe: Invalid header value detected

Affected version
2.1.7

Nirjonadda

Well-known member
To be clear (and maybe pedantic), the issue isn't that X-Ham-Report is an invalid header name (it's not, non-standard X- headers are not only extremely common but permitted), but that the header has an invalid value. This is something that could (should) be fixed in SpamAssassin.

If this bug from SpamAssassin then where we can report this issue? Please can you report this bug to SpamAssassin developer?
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.0 RC3).

Change log:
Improve error handling for invalid messages in the unsubscribe email address inbox
There may be a delay before changes are rolled out to the XenForo Community.
 

Mike

XenForo developer
Staff member
Just to clarify, the changes here generally improve the error handling here, though if the email isn't to spec, we still won't be able to parse it. This should prevent getting stuck on an email, for example, though depending on configuration, it might not end up feeling too different.

However, we do also log the contents of the mail now which should aid in debugging, so that we can indeed confirm what is invalid (in case there is ultimately a bug in the upstream email parsing library). So if you get this error after running 2.2, let us know.
 

Wutime

Well-known member
I've noticed I get these errors whenever someone "unsubscribes" using Apple Mail.

The email is never deleted from the mail inbox nor is the user marked as unsubscribing.

The only fix for me is to:

  • manually remove the email from the unsubscribe@ email account (so it doesn't continually trigger an error every time the cron runs)
  • manually unsubscribe the user in the XF user administration

Here's what the email always looks like:

1601332168164.png
 

Mike

XenForo developer
Staff member
The changes in 2.2 will help with the "manually remove the email" part, so it won't get stuck.

But if you still have the full, raw version of the email (including all of the headers as they were received), can you send it to me (via a conversation)? This will allow me to confirm the contents of the invalid header.
 

Nirjonadda

Well-known member
@Mike Still getting this type Server error log with v2.2.1

Code:
Laminas\Mail\Header\Exception\InvalidArgumentException: Bounce message processing failed: Invalid header value detected src/vendor/laminas/laminas-mail/src/Header/GenericHeader.php:64

Generated by: Unknown account Oct 30, 2020 at 8:53 PM

Stack trace

#0 src/vendor/laminas/laminas-mail/src/Headers.php(544): Laminas\Mail\Header\GenericHeader::splitHeaderLine('X-Ham-Report: S...')
#1 src/vendor/laminas/laminas-mail/src/Headers.php(284): Laminas\Mail\Headers->loadHeader('X-Ham-Report: S...')
#2 src/vendor/laminas/laminas-mail/src/Headers.php(105): Laminas\Mail\Headers->addHeaderLine('X-Ham-Report: S...')
#3 src/vendor/laminas/laminas-mime/src/Decode.php(150): Laminas\Mail\Headers::fromString('Return-Path: <c...', '
')
#4 src/vendor/laminas/laminas-mail/src/Storage/Part.php(103): Laminas\Mime\Decode::splitMessage('Return-Path: <c...', 'Return-Path: <c...', 'PGRpdiBkaXI9Imx...', '
', false)
#5 src/vendor/laminas/laminas-mail/src/Storage/Message.php(53): Laminas\Mail\Storage\Part->__construct(Array)
#6 src/XF/EmailBounce/Parser.php(169): Laminas\Mail\Storage\Message->__construct(Array)
#7 src/XF/EmailBounce/Processor.php(94): XF\EmailBounce\Parser->parseMessage('Return-Path: <c...')
#8 src/XF/EmailBounce/Processor.php(70): XF\EmailBounce\Processor->processMessage('Return-Path: <c...')
#9 src/XF/Job/EmailBounce.php(27): XF\EmailBounce\Processor->processFromStorage(Object(XF\Mail\Storage\Imap), G)
#10 src/XF/Job/Manager.php(258): XF\Job\EmailBounce->run(G)
#11 src/XF/Job/Manager.php(200): XF\Job\Manager->runJobInternal(Array, G)
#12 src/XF/Job/Manager.php(84): XF\Job\Manager->runJobEntry(Array, G)
#13 job.php(43): XF\Job\Manager->runQueue(false, 8)
#14 {main}

Request state

array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(91) "/threads/the_show.80169/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 

Chris D

XenForo developer
Staff member
As stated, if you can track down the specific email that triggered the error then we can investigate.

But if you still have the full, raw version of the email (including all of the headers as they were received), can you send it to me (via a conversation)? This will allow me to confirm the contents of the invalid header.
 

ActorMike

Well-known member
As stated, if you can track down the specific email that triggered the error then we can investigate.
We get about 2 of these messages every time we email our users out of 10,000. Not really concerning, but does generate a server error in the log. What can we do to resolve, if anything?


Code:
Laminas\Mail\Exception\RuntimeException: Bounce message processing failed: Line "Hello," does not match header format! src\vendor\laminas\laminas-mail\src\Headers.php:110

#0 src\vendor\laminas\laminas-mime\src\Decode.php(150): Laminas\Mail\Headers::fromString('Received: ; Wed...', '
')
#1 src\vendor\laminas\laminas-mail\src\Storage\Pop3.php(107): Laminas\Mime\Decode::splitMessage('Received: ; Wed...', 'Received: ; Wed...', 'Received: from ...')
#2 src\XF\EmailBounce\Processor.php(52): Laminas\Mail\Storage\Pop3->getRawContent(155)
#3 src\XF\Job\EmailBounce.php(27): XF\EmailBounce\Processor->processFromStorage(Object(XF\Mail\Storage\Pop3), 8)
#4 src\XF\Job\Manager.php(258): XF\Job\EmailBounce->run(8)
#5 src\XF\Job\Manager.php(200): XF\Job\Manager->runJobInternal(Array, 8)
#6 src\XF\Job\Manager.php(84): XF\Job\Manager->runJobEntry(Array, 8)
#7 job.php(43): XF\Job\Manager->runQueue(false, 8)
#8 {main}

Code:
Laminas\Mail\Exception\RuntimeException: Bounce message processing failed: Line "Hello," does not match header format! src\vendor\laminas\laminas-mail\src\Headers.php:110


#0 src\vendor\laminas\laminas-mime\src\Decode.php(150): Laminas\Mail\Headers::fromString('Content-Type: t...', '
')
#1 src\vendor\laminas\laminas-mime\src\Decode.php(81): Laminas\Mime\Decode::splitMessage('Content-Type: t...', 'Content-Type: t...', 'Unfortunately y...', '
')
#2 src\vendor\laminas\laminas-mail\src\Storage\Part.php(194): Laminas\Mime\Decode::splitMessageStruct('--=============...', '===============...')
#3 src\vendor\laminas\laminas-mail\src\Storage\Part.php(256): Laminas\Mail\Storage\Part->cacheContent()
#4 src\vendor\laminas\laminas-mail\src\Storage\Part.php(471): Laminas\Mail\Storage\Part->countParts()
#5 src\XF\EmailBounce\Parser.php(243): Laminas\Mail\Storage\Part->rewind()
#6 src\XF\EmailBounce\Parser.php(203): XF\EmailBounce\Parser->extractContent(Object(Laminas\Mail\Storage\Message), Object(XF\EmailBounce\ParseResult))
#7 src\XF\EmailBounce\Processor.php(94): XF\EmailBounce\Parser->parseMessage(Object(Laminas\Mail\Storage\Message))
#8 src\XF\EmailBounce\Processor.php(70): XF\EmailBounce\Processor->processMessage('Return-Path: <>...')
#9 src\XF\Job\EmailBounce.php(27): XF\EmailBounce\Processor->processFromStorage(Object(XF\Mail\Storage\Pop3), 8)
#10 src\XF\Job\Manager.php(258): XF\Job\EmailBounce->run(8)
#11 src\XF\Job\Manager.php(200): XF\Job\Manager->runJobInternal(Array, 8)
#12 src\XF\Job\Manager.php(84): XF\Job\Manager->runJobEntry(Array, 8)
#13 job.php(43): XF\Job\Manager->runQueue(false, 8)
#14 {main}
 

Mike

XenForo developer
Staff member
We get about 2 of these messages every time we email our users out of 10,000. Not really concerning, but does generate a server error in the log. What can we do to resolve, if anything?
There's probably not a lot you can do to resolve it if the mail itself is invalid (as the processor is quite strict on the standards).

The mail will be included in the bounce log. It will likely display with several of the fields as blank (or unknown). The date should correspond with when you received the error. If you want me to look at the email, you can click "view" and send me the raw output via a conversation. It's likely the email is actually invalid (based on the standard at least) and thus there probably won't be anything else we'd do. It may point to the email address that's triggering it though.
 

ActorMike

Well-known member
Here is one that has appeared three times this week.
ErrorException: Bounce message processing failed: [E_WARNING] str_split(): The length of each segment must be greater than zero src\vendor\laminas\laminas-mail\src\Header\ContentDisposition.php:152 Generated by: Unknown account Jun 10, 2021 at 5:23 AM

There is only one email even close to that time:


<removed by moderator>
 
Last edited by a moderator:
Top