How to send custom mail in wordpress

In WordPress, you can send custom mail using the wp_mail() function, which is a built-in function that allows you to send emails from your WordPress site. Here's a step-by-step guide on how to send custom mail in WordPress:

Method 1: Using wp_mail() function

You can use the wp_mail() function to send custom mail in WordPress. This function takes four arguments:

Here's an example:

wp_mail( '[email protected]', 'Custom Email Subject', 'This is a custom email message.' );

You can also add headers to the email using the $headers argument:

$headers = array(
    'From: Your Name <[email protected]>',
    'Content-Type: text/plain; charset=UTF-8'
);
wp_mail( '[email protected]', 'Custom Email Subject', 'This is a custom email message.', $headers );

Method 2: Using a plugin

There are many plugins available that allow you to send custom mail in WordPress, such as:

To use a plugin, you'll need to install and activate it, then configure it according to the plugin's instructions.

Method 3: Using a theme function

You can also create a custom theme function to send custom mail in WordPress. This method requires some PHP coding skills, but it gives you more control over the email sending process.

Here's an example of how you can create a custom theme function to send custom mail:

function send_custom_email() {
    $to = '[email protected]';
    $subject = 'Custom Email Subject';
    $message = 'This is a custom email message.';
    $headers = array(
        'From: Your Name <[email protected]>',
        'Content-Type: text/plain; charset=UTF-8'
    );
    wp_mail( $to, $subject, $message, $headers );
}
add_action( 'wp_footer', 'send_custom_email' );

In this example, we're creating a custom theme function called send_custom_email() that sends a custom email to the recipient. We're using the wp_mail() function to send the email, and we're adding headers to the email using the $headers argument.

To use this function, you'll need to add it to your theme's functions.php file, and then use the add_action() function to hook it to the wp_footer action hook.