WC_Email::send()
Send an email.
Method of the class: WC_Email{}
Hooks from the method
Return
true|false
. success
Usage
$WC_Email = new WC_Email(); $WC_Email->send( $to, $subject, $message, $headers, $attachments );
- $to(string) (required)
- Email to.
- $subject(string) (required)
- Email subject.
- $message(string) (required)
- Email message.
- $headers(string) (required)
- Email headers.
- $attachments(array) (required)
- Email attachments.
WC_Email::send() WC Email::send code WC 9.3.1
public function send( $to, $subject, $message, $headers, $attachments ) { add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); $message = apply_filters( 'woocommerce_mail_content', $this->style_inline( $message ) ); $mail_callback = apply_filters( 'woocommerce_mail_callback', 'wp_mail', $this ); $mail_callback_params = apply_filters( 'woocommerce_mail_callback_params', array( $to, wp_specialchars_decode( $subject ), $message, $headers, $attachments ), $this ); $return = $mail_callback( ...$mail_callback_params ); remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); // Clear the AltBody (if set) so that it does not leak across to different emails. $this->clear_alt_body_field(); /** * Action hook fired when an email is sent. * * @since 5.6.0 * @param bool $return Whether the email was sent successfully. * @param int $id Email ID. * @param WC_Email $this WC_Email instance. */ do_action( 'woocommerce_email_sent', $return, $this->id, $this ); return $return; }