WordPress cannot send emails by itself. It has to rely on an email server to do the job. You can set up an SMTP email server or use a third-party service. Generally, you will install a WordPress plugin and configure it with SMTP information. After that, WordPress can start sending emails.
However, setting up your own email server is not a good idea. Because most likely, your email will go straight to the recipient’s junk/spam box. Please use a reputable third party service that supports SMTP. An internet search gives me some services like Sendinblue, Mailjet, SendGrid, etc. (you can search for more results by yourself). These services all offer a free plan with some limitations, but they support SMTP and include WordPress plugins. Refer to the following plugin pages for how to integrate them into your website: Sendinblue, Mailjet, SendGrid.
If you want to set up an email server yourself, follow the tutorial How To Install and Configure Postfix as a Send-Only SMTP Server on Ubuntu 20.04. Once you have an SMTP server, install an SMTP plugin for WordPress such as WP Mail SMTP and configure it with the SMTP information.
Postfix is a mail transfer agent (MTA), an application used to send and receive email. It can be configured so that it can be used to send emails by local application only. In this tutorial, you'll install and configure Postfix on Ubuntu 20.04 as a send-only SMTP server. You'll also request free TLS certificates from Let's Encrypt for your domain and encrypt the outbound emails using them.