Reputation: 989
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/
Upvotes: 2
Views: 972
Reputation: 989
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
$email->send( $to, $subject, $message, $headers, $attachments );
to
$return = $email->send( $to, $subject, $message, $headers, $attachments );
return $return;
**OR**
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.
Upvotes: 1
Reputation: 4054
You should var_dump $send, and see whats returned. Else why dont you try using the wordpress native mail function?
$multiple_recipients = array(
'[email protected]',
'[email protected]'
);
$subj = 'The email subject';
$body = 'This is the body of the email';
if(wp_mail( $multiple_recipients, $subj, $body )){
// Mail Sent Successfully
}else{
// Mail not sent
}
Upvotes: 0