MDL-13811: Merged fix to work when email is disabled