I am trying to send mail in wordpress using
$subject = 'WC Send Mail Test';
// load the mailer
$mailer = WC()->mailer();
$send = $mailer->send( get_option( 'admin_email' ), $subject, $mailer->wrap_message( $subject, 'a test message' ), '', '' );
if($send){
echo "Sent";
}else{
echo "Not sent";
}
This function works fine but i’m not able to track mail is sent or not.
$send is always NULL
Above code is taken from http://develop.woothemes.com/woocommerce/2014/10/2-3-emails/
Finally I got the solution. I’m trying to digging out the woocommerce code and find the woocommerce use this file to send email
woocommerce/includes/class-wc-emails.php
Around line no. 214 I found the send method.
I have change the code
to
Since changing the wordpress core functionality is a bad habit so i get a proper way to override the wordpress core functionality.
I have just created a directory structure inside the child-theme like
woocommerce/includes
Here you have to create a file named class-wc-emails.php and paste your edited file code here.
Please don’t go for OR section this is not working for me.
You should var_dump $send, and see whats returned. Else why dont you try using the wordpress native mail function?