Skip to content

Instantly share code, notes, and snippets.

@bacoords
Created August 26, 2022 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bacoords/ad33e19e5973aa016d5c65bacb0ca96f to your computer and use it in GitHub Desktop.
Save bacoords/ad33e19e5973aa016d5c65bacb0ca96f to your computer and use it in GitHub Desktop.
Since wc_mail doesn't seem to work perfectly, a custom version
<?php
/**
* Our custom alternative to wc_mail.
*
* @param mixed $to Receiver.
* @param mixed $subject Subject.
* @param mixed $message Message.
* @param string $headers Headers. (default: "Content-Type: text/html\r\n").
* @param string $attachments Attachments. (default: "").
* @return bool
*/
function prefix_mail( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "" ) {
if( ! class_exists( 'WC_Emails' ) ) { include_once WC_ABSPATH . 'includes/class-wc-emails.php'; }
$mailer = WC()->mailer();
$message = $mailer->wrap_message( $subject, $message );
return $mailer->send( $to, $subject, $message, $headers, $attachments );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment