Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    magento-marketplace-mod

    Magento 2- Send mail using your smtp server

    Here we learn how to send mail  using our smtp detail in magento2

    For this we need to override mageto \Magento\Framework\Mail\Transport class by your custom model class

    We have a complete module for smtp setup. You can check here SMTP Configurator for Magento2 here.

    We can do it in two step

    1# For override we need to write code in module di.xml file at location app/code/NameSpace/ModuleName/etc


    2# Now we’ll define our  Transport model in our custom module


    Now all mail goes from your magento 2 instance using your smtp server 🙂

    . . .

    Comments (37)

    Add Your Comment

  • BJ
    After upgrading Magento 2.2.7 to 2.3.5-p1 SMTP email is not working. Can you please help me if I have to do any changes in my code?
    • Subhangi
      Hello,

      If you are facing issue with the module in working with Magento version 2.3.5. Then, you can click here to create a ticket and the team will assist you accordingly.

      Thank you !!

  • Muhammad Usman
    helpful..
  • DB
    I’m having trouble after upgrading to 2.1.9. I cant go to 2.2 yet. Should i try this code change?
    • Webkul Support
      yes you can use it with following update
      For magento2 version 2.2.Xyou need to do following updateSetp 1add following method in NameSpaceModuleNameModelTransport.php (Model file)/** * @inheritdoc */public function getMessage() { return $this->message;}Step 2=>update file app/code/NameSpace/ModuleName/etc/di.xml

      Thanks Abhishek

  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close