• Resolved loopforever

    (@loopforever)


    Hello,
    I am trying to send an e-mail from the function.php file.
    I have a php file in my child theme. This is an email template. I want to use this as $ message in wp_mail function. Is there any way to include this? I have tried many ways but have not been successful.

    Update:
    I noticed that I spelled it wrong. Thanks.

    File path:
    …/my-child/a-file.php

    ob_start();
    include(get_stylesheet_directory() . '/a-file.php');
    $email_content = ob_get_contents();
    ob_end_clean();
    $headers = array('Content-Type: text/html; charset=UTF-8');
    $subject = 'Your order #'.$order_id.' has been cancelled';
    wp_mail($to_email, '$subject', $email_content, $headers);

The topic ‘wp_mail for a custom template’ is closed to new replies.