How to fix the «Email has a wrong format» failure while upgrading Magento from 2.1.x to 2.2.x?

Locate the line:

Add the following line above:

$orderAddress['email'] = $orderAddress['email'] ?: 'empty@empty.com';