I developed under WordPress a page that receives a JSON containing an email address and automatically sends an email using wp_mail.
Here is the code related to wp_mail :
// Not loading WP templates...
define( 'WP_USE_THEMES', false );
// Load WordPress Core (make sure the path is correct)
$path = preg_replace('/wp-content.*$/','',__DIR__);
$path = preg_replace('/wp-content(?!.*wp-content).*/','',__DIR__);
include($path.'wp-load.php');
$to = $email ;
$subject = 'Arbre planté';
$body = '<html><body><h1>Hello World!</h1></body></html>';
$headers = array('Content-Type: text/html; charset=UTF-8','From: Kevin Brosseau <kevin@warenghem.com>');
wp_mail( $to, $subject, $body, $headers );
The issues are:
- The subject is in the body
- The "from" email addres "is in the subject
- Emails do not always arrive (rarely)
- HTML does not work
- I have the following PHP warning:
<b> Warning </b>: call_user_func_array () expects parameter 1 to be a valid callback, function 'wpb_sender_email' not found or invalid function name in <b> / home / clients / 401db14e9680969ee897423a6a744d86 /warenghem/wp-includes/class-wp-hook.php </b> on line <b> 287 </b> <br />
I looked for solutions in vain ... Could you help me?
Have a good day