How to change magento2 send mail id

In Magento 2, you can change the sender email ID for system emails by modifying the admin_email and from_email settings in the Magento configuration files. Here are the steps:

Method 1: Using the Magento Admin Panel

  1. Log in to the Magento Admin Panel.
  2. Go to Stores > Configuration.
  3. In the Advanced section, click on System.
  4. Scroll down to the Email Options section.
  5. Update the Admin Email field with the new email address you want to use as the sender ID.
  6. Click Save Config.

Method 2: Editing the Magento configuration files

  1. Open the app/etc/env.php file in a text editor.

  2. Find the following lines:

    'default_sendmail_from_email' => '[email protected]',
    'default_sendmail_from_name' => 'Your Current Name',

    Replace [email protected] with the new email address you want to use as the sender ID.

  3. Save the changes to the env.php file.

Method 3: Using a custom module

You can also create a custom module to change the sender email ID. Here's an example:

  1. Create a new directory for your custom module, e.g., MyCompany_Sendmail.
  2. Create a registration.php file in the MyCompany_Sendmail directory with the following code:
    <?php
    \Magento\Framework\Component\ComponentRegistrar::register(
     \Magento\Framework\Component\ComponentRegistrar::MODULE,
     'MyCompany_Sendmail',
     __DIR__
    );
  3. Create a etc/module.xml file in the MyCompany_Sendmail directory with the following code:
    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/moduleconfig.xsd">
     <module name="MyCompany_Sendmail" setup_version="1.0.0">
         <sequence>
             <module name="Magento_Sendmail"/>
         </sequence>
     </module>
    </config>
  4. Create a etc/config.xml file in the MyCompany_Sendmail directory with the following code:
    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/config.xsd">
     <global>
         <email>
             <sendmail>
                 <from_email>[email protected]</from_email>
             </sendmail>
         </email>
     </global>
    </config>
  5. Run the following command to deploy the module:
    php bin/magento module:deploy MyCompany_Sendmail
  6. Run the following command to enable the module:
    php bin/magento module:enable MyCompany_Sendmail

    After making these changes, the sender email ID for system emails in Magento 2 should be updated to the new email address you specified.