How to apply normal php mail function in wordpress

In WordPress, the wp_mail() function is the recommended way to send emails. However, if you still want to use the traditional PHP mail() function, you can do so by using the wp_mail filter and modifying the wp_mail function to use the mail() function instead.

Here's an example of how you can do this:

function use_php_mail_function() {
    return 'mail';
}
add_filter( 'wp_mail', 'use_php_mail_function' );

This code adds a filter to the wp_mail function and returns the string 'mail', which tells WordPress to use the mail() function instead of the default wp_smtp function.

You can also use the wp_mail function directly in your theme or plugin files, like this:

<?php
$to      = '[email protected]';
$subject = 'Test email';
$message = 'This is a test email';
$headers = array('From: [email protected]');

wp_mail( $to, $subject, $message, $headers );
?>

However, keep in mind that using the mail() function directly can lead to issues with email delivery, especially if you're using a shared hosting environment or a server with strict email sending limits.

It's also important to note that the wp_mail function is designed to work with WordPress's built-in email handling system, which includes features like email queuing and retrying failed emails. If you use the mail() function directly, you'll need to implement these features yourself.

In general, it's recommended to use the wp_mail function and its built-in features to send emails in WordPress. If you need more control over the email sending process, you can use a third-party email plugin or service that provides more advanced features.