The way you’re applying the headers is incorrect. You set a “from” address in the headers as a string, and then you immediately overwrite that with an array (so the “from” address is lost). (You’re also setting the $from address twice)
Try it this way:
function send_email(){
$to = $email;
$subject = "Lamza Activation";
$activationEmail="";
$from = "testing <[email protected]>";
$headers[] = "From:" . $from . PHP_EOL;
$headers[] = 'Content-Type: text/html; charset=UTF-8';
wp_mail($to, $subject, $activationEmail, $headers);
}
OR, you could also use the wp_mail
filters to set the from address and content type instead.
function send_email(){
$to = $email;
$subject = "Lamza Activation";
$activationEmail="";
wp_mail($to, $subject, $activationEmail);
}
add_filter( 'wp_mail_from', function( $from ) {
return "[email protected]";
});
add_filter( 'wp_mail_from_name', function( $from_name ) {
return "testing";
});
add_filter( 'wp_mail_content_type', function( $content_type {
return 'text/html';
});
// This one you may not need as WP defaults to UTF-8...
add_filter( 'wp_mail_charset', function( $charset ) {
return 'UTF-8';
});