Fixed Exception when sending E-Mails / XFI: Invalid email imported vBulletin

Kirby

Well-known member
Affected version
2.1.9
We did an import from vBulletin 4 and afterwards tried to email users which generated an exception (personal data redacted) which stopped execution:

Code:
Swift_RfcComplianceException: Address in mailbox given [foo...bar@domain.tld] does not comply with RFC 2822, 3.6.2. src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php:345
 
#0 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php(261): Swift_Mime_Headers_MailboxHeader->_assertValidAddress('foo...bar@do...')
#1 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php(106): Swift_Mime_Headers_MailboxHeader->normalizeMailboxes(Array)
#2 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php(63): Swift_Mime_Headers_MailboxHeader->setNameAddresses(Array)
#3 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php(58): Swift_Mime_Headers_MailboxHeader->setFieldBodyModel(Array)
#4 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php(68): Swift_Mime_SimpleHeaderFactory->createMailboxHeader('To', Array)
#5 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php(329): Swift_Mime_SimpleHeaderSet->addMailboxHeader('To', Array)
#6 src/XF/Mail/Mail.php(54): Swift_Mime_SimpleMessage->setTo(Array, 'foobar')
#7 src/XF/Mail/Mail.php(88): XF\Mail\Mail->setTo('foo...bar@do...', 'foobar')
#8 src/XF/Job/UserEmail.php(132): XF\Mail\Mail->setToUser(Object(XFMG\XF\Entity\User))
#9 src/XF/Job/UserEmail.php(65): XF\Job\UserEmail->getMail(Object(XFMG\XF\Entity\User))
#10 src/XF/Job/AbstractUserCriteriaJob.php(59): XF\Job\UserEmail->executeAction(Object(XFMG\XF\Entity\User))
#11 src/XF/Job/Manager.php(253): XF\Job\AbstractUserCriteriaJob->run(G)
#12 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#13 src/XF/Job/Manager.php(111): XF\Job\Manager->runJobEntry(Array, G)
#14 src/XF/Admin/Controller/Tools.php(120): XF\Job\Manager->runByIds(Array, 8)
#15 src/XF/Mvc/Dispatcher.php(350): XF\Admin\Controller\Tools->actionRunJob(Object(XF\Mvc\ParameterBag))
#16 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'RunJob', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Tools), NULL)
#17 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Tools), NULL)
#18 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#19 src/XF/App.php(2184): XF\Mvc\Dispatcher->run()
#20 src/XF.php(391): XF\App->run()
#21 admin.php(13): XF::runApp('XF\\Admin\\App')
#22 {main}

The email address was foo...bar@domain.tld (eg. had three consecutive dots) which is not valid (eg. is not accepted as valid if manually trying to creae an account with such an email address).

Ideally the importer should set such accounts as state = bounced and the send-process should log an exception and not abort completely.
 
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.1.10).

Change log:
When importing users with invalid email addresses, correctly set their user states.
There may be a delay before changes are rolled out to the XenForo Community.
 
Note that for non-valid accounts with invalid emails, we now remove the email on import. (A valid account will be moved to email_bounce. This doesn't totally prevent emails from being sent to the address, but it does eliminate most cases and it doesn't remove potentially relevant data.)

...and the send-process should log an exception and not abort completely.
Just to clarify this point: this is how the code functions. However, if you have debug mode enabled, it will throw the exception immediately on the assumption that it's likely something that needs to be checked in the code.
 
However, if you have debug mode enabled, it will throw the exception immediately on the assumption that it's likely something that needs to be checked in the code.
Hmm ... I just tested this again and I do get the exception on screen without debug mode enabled.
 
Back
Top Bottom