Magento 2 handles the email address at the Global and Website level.
You can set global or website level for email id from Stores -> Configuration -> Customer -> Customer Configuration -> Account Sharing Options
Choose Share Customer Accounts Global or Website level.
If you have kept the Website level, you need to create a separate account for different websites in a single Magento instance.
You can check whether the email id exists or not for a specific website by below code snippet.
namespace Path\To\Model; use Magento\Customer\Api\AccountManagementInterface; use Magento\Store\Model\StoreManagerInterface; class EmailCheck { /** * @var AccountManagementInterface */ private $customerAccountManagement; /** * @var StoreManagerInterface */ private $storeManager; /** * Data constructor. * * @param AccountManagementInterface $customerAccountManagement * @param StoreManagerInterface $storeManager */ public function __construct( AccountManagementInterface $customerAccountManagement, StoreManagerInterface $storeManager, ) { $this->customerAccountManagement = $customerAccountManagement; $this->storeManager = $storeManager; } /** * * @return bool */ public function emailExistOrNot(): bool { $email = "rakesh_jesadiya@exmaple.com"; $websiteId = (int)$this->storeManager->getWebsite()->getId(); $isEmailNotExists = $this->customerAccountManagement->isEmailAvailable($email, $websiteId); return $isEmailNotExists; } }
A response will be boolean value.
If the email does not exist return the result as true otherwise return false;