I caught data $email and $comment that I must send


namespace Dev\ProductComments\Observer;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;

class EmailObserver implements ObserverInterface

    public function __construct()
        // Observer initialization code...
        // You can use dependency injection to get any class this observer may need.

    public function execute(\Magento\Framework\Event\Observer $observer)
        $email = $observer->getData('sentEmail');
        $comment = $observer->getData('sentComment');



Mailhog works like an smtp server

So you host mailhog somewhere. The mailhog interface gives you the mail details you need. When working locally I use docker.

Then use an extension in magento which allows you to configure smtp and all your magento mail goes to mailhog

You cant just do it for one process via magento. You could code using pure php and a third party library and hard code mailhog credentials.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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