How to setup Mailhog in Ubuntu PHP Magento 2?

MailHog tools are used to test mail functionality from your local development environment.

If you are using Linux/Ubuntu OS with PHP language and want to set up MailHog for your local setup. MailHog tool is the best suited for your system to test web application mails.

First You need to install MailHog using the Command Line Interface (CLI),

Install MailHog,  go get github.com/mailhog/MailHog

Mhsendmail is a Send mail utility created to send emails via MailHog.

Install mhsendmail,  go get github.com/mailhog/mhsendmail

copy MailHog and mhsendmail to the /usr/local/bin path,

Just replace system_user with your system username.

You can get the current username of the system in Linux by command,

Now Modify the php.ini to setup MailHog path,
I am working with PHP 7.4 version, php.ini path location would be /etc/php/7.4/apache2/

From Command Line, Run the command to modify the file,
sudo gedit /etc/php/7.4/apache2/php.ini

Now update ;sendmail_path = with the given line. Remove the semicolon from the starting and update the path,
sendmail_path = /usr/local/bin/mhsendmail
Save the file and restart the PHP to get it to work.

Final Step:

Go To CLI, run the command,

You will see URLs like http://0.0.0.0:8025/
Open this URL in the browser and you will be able to see the web interface of  Mailhog.

You can see more details about MailHog by MailHog README.md link.

How Magento send Order, shipment, invoice and creditmemo emails in Magento 2?

How Magento Send Order Related Emails or Flow of the Order Sender Mail?

Magento sends order-related emails after the order performs an action like Place order, generate Invoice, generate shipment, and credit memo.

Magento_Sales module used for sending Order related emails to the customer.
You can start debugging from the Respective PHP class for the specific email in Magento 2.
Continue reading “How Magento send Order, shipment, invoice and creditmemo emails in Magento 2?”

How Magento send email to Password reset/changed of Customer?

Customer Password is reset or changed in Magento 2, Password Reset Mail is getting to the customer for password reset or changed action.

Magento_Customer Module is responsible for sending an email to the specific customers for a password reset action. Continue reading “How Magento send email to Password reset/changed of Customer?”