First, it is necessary to access the backoffice of our Moodle with the administrator credentials.
Then we have to access the Email function, following this path "Site Administration -> Plugins -> Message outputs -> Email and configure your email"
We configure the SMTP servers, SMTP username, SMTP password.
This would be an example of how it would look: