已将以下简单代码添加到functions.php中,以从Woocommerce Admin页面发送简单电子邮件,但是由于某些原因它无法正常工作。我想念什么吗?
// Custom metabox to send email to customer
add_action( 'add_meta_boxes', 'add_meta_boxesws' );
function add_meta_boxesws()
{
add_meta_box( 'custom_order_meta_box', __( 'Send email to customer' ),
'custom_metabox_content', 'shop_order', 'normal', 'default');
}
function custom_metabox_content(){
echo "<h2>Send email to customer</h2>";
echo "<form id='post' action='' method='POST'>";
echo "<input type='submit' name='send_email' value='Send email' id='submit';'/>";
echo "</form>";
$headers[] = 'From: My Email <me@myemail.com>';
$to = 'recipient@recipientsemail.com';
$subject = 'Direct email from me';
$message = 'We are testing our new email feature';
if(isset($_POST['send_email'])) {
wp_mail( $to, $subject, $message, $headers);
}
}