How to get admin user mail id in magento 2

In Magento 2, you can get the admin user's email ID in several ways:

  1. Using the Magento\Framework\App\ObjectManager:
    
    use Magento\Framework\App\ObjectManager;

$objectManager = ObjectManager::getInstance(); $adminUser = $objectManager->get('Magento\User\Model\User'); $adminEmail = $adminUser->getEmail();

2. **Using the `Magento\User\Model\UserFactory`**:
```php
use Magento\User\Model\UserFactory;

$userFactory = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\User\Model\UserFactory');
$adminUser = $userFactory->create()->load($adminUser->getId());
$adminEmail = $adminUser->getEmail();
  1. Using the Magento\Framework\App\Config\ScopeConfigInterface:
    
    use Magento\Framework\App\Config\ScopeConfigInterface;

$scopeConfig = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\Config\ScopeConfigInterface'); $adminEmail = $scopeConfig->getValue('admin/email', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);


Note that the above code snippets assume that you are running the code in a Magento 2 module or a custom script. If you are running the code in a controller or a block, you may need to inject the necessary dependencies or use the `@var` annotation to inject the required objects.

Also, keep in mind that the admin user's email ID may not be available if the admin user has not set an email address or if the email address is not verified.