2

As i see i think you probably want to override SEND method. But i think the best practice is to use Plugin to change the thing as you want. It will be safe in the future Otherwise, if you still want to override the original class , you have to re-define all private variables to use again in the new class.


2

Try below code etc/di.xml <preference for="Magento\Contact\Model\Mail" type="Vendor\Module\Model\Mail" /> Add 2 dependency in your Vendor/Module/Model/Mail.php use Magento\Contact\Model\MailInterface; use Magento\Contact\Model\ConfigInterface; Check below code <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING....


1

In this scenario, I think you can create your own class(duplicate with public variables) in your custom module and set the preference in di.xml file of your custom module. Add the following element in your custom module di.xml <preference for="Magento\Contact\Model\Mail" type="Vendor\CustomModule\Model\Mail" /> Hope this is helpful.


Only top voted, non community-wiki answers of a minimum length are eligible