Fixed XF:EmailBounce fails when the from-address has an ip address for the domain part

Affected version
2.1.3

Xon

Well-known member
Zend\Mail\Address::fromString throws an exception if the from string is in the format of; Name <admin@127.0.0.1>

Code:
Job XF:EmailBounce: '<IP ADDRESS>' is not a valid hostname for the email address

#0 src/vendor-patch/Zend/Mail/Address.php(53): Zend\Mail\Address->__construct('admin@xxx.yyy.zz...', 'Softaculous', '')
#1 src/vendor/zendframework/zend-mail/src/Header/AbstractAddressList.php(86): Zend\Mail\Address::fromString('Softaculous <ad...', '')
#2 [internal function]: Zend\Mail\Header\AbstractAddressList::Zend\Mail\Header\{closure}('Softaculous <ad...')
#3 src/vendor/zendframework/zend-mail/src/Header/AbstractAddressList.php(88): array_map(Object(Closure), Array)
#4 src/vendor-patch/Zend/Mail/Headers.php(485): Zend\Mail\Header\AbstractAddressList::fromString('From: Softaculo...')
#5 src/vendor-patch/Zend/Mail/Headers.php(232): Zend\Mail\Headers->loadHeader('From: Softaculo...')
#6 src/vendor-patch/Zend/Mail/Headers.php(96): Zend\Mail\Headers->addHeaderLine('From: Softaculo...')
#7 src/vendor/zendframework/zend-mime/src/Decode.php(149): Zend\Mail\Headers::fromString('Return-path: <p...', '
')
#8 src/vendor/zendframework/zend-mail/src/Storage/Pop3.php(106): Zend\Mime\Decode::splitMessage('Return-path: <p...', 'Return-path: <p...', 'The automatic b...')
#9 src/XF/EmailBounce/Processor.php(48): Zend\Mail\Storage\Pop3->getRawContent(1)
#10 src/XF/Job/EmailBounce.php(27): XF\EmailBounce\Processor->processFromStorage(Object(Zend\Mail\Storage\Pop3), G)
#11 src/XF/Job/Manager.php(253): XF\Job\EmailBounce->run(G)
#12 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#13 src/XF/Job/Manager.php(79): XF\Job\Manager->runJobEntry(Array, G)
#14 job.php(42): XF\Job\Manager->runQueue(false, 8)
#15 {main}
 

Xon

Well-known member
This can be easily fixed by changing;
PHP:
// *** XF #161234 28/02/2019 ***
$emailAddressValidator = new EmailAddressValidator([
   'allow' => Hostname::ALLOW_DNS | Hostname::ALLOW_LOCAL,
 'strict' => false
]);
to
PHP:
// *** XF #161234 28/02/2019 ***
$emailAddressValidator = new EmailAddressValidator([
   'allow' => Hostname::ALLOW_DNS | Hostname::ALLOW_LOCAL | Hostname::ALLOW_IP,
 'strict' => false
]);
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.4).

Change log:
Allow IP hostnames in email addresses
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Top