TutorialsApps

Setting up mail forms via SMTP in Magento 2.4.x

This tutorial presents how to set up a mail form via SMTP authentication in the Magento application.

Views 365Updated 5 luniPublished on 04/07/2022by Cătălin Adrian

Introduction

This tutorial explains how to set up email forms using the SMTP protocol in Magento 2.4.x.

Requirements:

  • A valid VPS hosting account and domain
  • The Magento application installed on hosting, access to its administration panel, and Terminal access through cPanel
  • A mailbox created in the hosting panel that will be used for sending emails

Steps to follow:

Initially, Magento does not come in its construction with the SMTP mail function installed. Therefore, it will be necessary to separately install a module capable of implementing this function.

  • Access the cPanel hosting administration panel and then the Terminal plugin or SSH console. Navigate to the path /home/user/public_html or to the folder where the application is installed.
  • A user and a password in the form of keys generated from the Mageplaza platform are required, where you must have an account created.

Mageplaza account

  • Generate a pair of access keys by pressing the Create new access keys button.

Chei de acces Mageplaza

  • The keys are generated automatically, representing the user and password in the form:

Chei Mageplaza

  • If the generated keys are not functional, you can use the test keys provided by Mageplaza for the free modules.

User: 4e947606bf2552e4dad4910bd1928b08

Pass: 30ff4445ebad7885b012fdc667487096

  • From the SSH terminal, install the SMTP module by running the commands:

composer require mageplaza/module-smtp

The console will request the previously generated keys.

SMTP composer install

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f

  • Access the Magento admin interface to configure the SMTP module.

Login Magento

  • From the left menu, select Stores -> Settings -> Configurations.

Configurare Magento

  • From the Mageplaza Extensions menu, select the SMTP sub-menu.

Mageplaza SMTP

  • Activate the SMTP extension by filling in the name, email address, and clicking Activate Now in the Module Information section.

Activare extensie SMTP

  • In the General Configuration section:

1. Enable Mageplaza SMTP: Select Yes.

Activare SMTP

2. Log Emails: Select Yes to keep a log.

Logare mesaje

3. Clean Email Log Every: Set the number of days to retain the log.

Istoric log-uri

4. Blacklist: Enter addresses or patterns excluded from sending.

Blacklist SMTP Magento

  • In the SMTP Configuration Options section:

1. Host: Fill in the email server (e.g., mail.domain.com).

Nume server email

2. Port: Fill in the secure port 465.

Port SMTP

3. Protocol: Choose SSL.

Protocol de autentificare

4. Authentication: Select LOGIN.

Autentificare SMTP Magento

5. Username: Fill in the email account user.

Utilizator mail Magento

6. Password: Fill in the email box password.

Parola SMTP Magento

7. Return-Path Email: Enter the response address (identical to the sending address).

Adresa de răspuns

  • Test the settings in the Send Test Email section.

Testare setări

  • Press Save Config to save the configurations.

Salvare configurație