I have a special form that when filled needs to send a notification mail to the admin. I used a system.xml to have it selected and stored in the database :

    <field id="identity" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">

Then I can retrieve it like that :


And I get e.g. the string "Sales" that correspond to the entry in vendor/magento/module-email/etc/config.xml :

            <email>[email protected]</email>

Is there a way to easily retrieve the email corresponding to the name ?

In the example, I told "Sales" but it can be changed as there is a dropdown so I need to be able to map the name to the email rather that hardcode the sales email address.

1 Answer 1

use Magento\Framework\Mail\Template\SenderResolverInterface $senderResolver

$identity = $this->senderResolver->resolve($this->scopeConfig->getValue(


The variable $identity will contain an array with the name and the email.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.