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
- Log in to the Magento Admin Panel.
- Go to Stores > Configuration.
- In the Advanced section, click on System.
- Scroll down to the Email Options section.
- Update the Admin Email field with the new email address you want to use as the sender ID.
- Click Save Config.
Method 2: Editing the Magento configuration files
-
Open the
app/etc/env.php
file in a text editor. -
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. -
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:
- Create a new directory for your custom module, e.g.,
MyCompany_Sendmail
. - Create a
registration.php
file in theMyCompany_Sendmail
directory with the following code:<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'MyCompany_Sendmail', __DIR__ );
- Create a
etc/module.xml
file in theMyCompany_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>
- Create a
etc/config.xml
file in theMyCompany_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>
- Run the following command to deploy the module:
php bin/magento module:deploy MyCompany_Sendmail
- 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.