How to send email in WordPress using wp_mail() function
You can use the wp_mail() function in your theme’s functions.php file or in a custom plugin.
function send_custom_email() {
$to = 'recipient@email.com'; // Email address to send to
$subject = 'Hello from WordPress'; // Subject of the mail
$message = 'This is a test email sent from WordPress.'; // Email content
$headers = array(
'Content-Type: text/html; charset=UTF-8',
'From: sender@email.com'
); // Sender email
//Send the mail
wp_mail($to, $subject, $message, $headers);
}
$to: Recipient’s email address.
$subject: Subject line of the email.
$message: Body of the email.
$headers: array of additional headers like Content-Type.