for those with the same issue, here is my inteire code working, I had to put the img tag inside the subject body tag, also once I was using $_POST the link just didnt work, had made a work around using a word "[imagem]" to replace with img tag and the link uploaded.
<div class="container">
<div class="email_maker">
<h2>Enviar vários emails</h2>
<form action="?page=editor_redes" method="post" enctype="multipart/form-data">
<label for="emails_assunto">Assunto:</label>
<input type="text" name="emails_assunto" required><br>
<label for="emails_msg">corpo de email:</label>
<textarea name="emails_msg" rows="20" cols="80" required></textarea><br>
<label for="emails_image">Banner publicitário: use no texto acima [imagem] e aqui apenas links de imagens online</label>
<input type="text" name="emails_image"/><br>
<div class="emails_conf">
<input type="file" name="emails_file" required/>
<label for="emails_file">Destinatários:</label>
</div><br><br>
<input type="submit" name="emails_submit" value="enviar" />
</form>
</div>
<div class="email_preview">
</div>
</div>
<style media="screen">
.container{display:flex;}
.email_maker{width:50%;}
.email_maker h2{color:orange;margin-top:40px;margin-bottom:30px;}
.email_maker form{display:grid;}
.email_maker label[for=emails_file]{float:right;padding-right:10px;padding-top: 7px;}
.email_maker input[type=file]{float:right; color:gray;}
.email_maker input[type=submit]{background:lightyellow;border-radius: 7px;}
</style>
if(isset($_FILES['emails_file'])){
$path_to_wp = $_FILES['emails_file']['tmp_name'];
$file = fopen($path_to_wp,"r");
if (strpos($_POST['emails_msg'], '[imagem]')) {
$ms = explode('[imagem]',$_POST['emails_msg']);
$msg = $ms[0];
$msg .= "<a href='https://ittca.github.io'><img src='".$_POST['emails_image']."'></a>";
$msg .= $ms[1];
} else {
$msg = $_POST['emails_msg'];
}
$body = "<html><head></head><body>";
$body .= $msg;
$body .= "</body></html>";
$a = 1;
while(!feof($file)){
$to = fgets($file);
if($to != ""){
$headers = array('Content-Type: text/html; charset=UTF-8','From: [email protected]');
$enviado = wp_mail($to, $_POST['emails_assunto'], $body, $headers);
if($enviado){
echo '<p>'.$a.' [<a style="color:green;">OK</a>] '.$to.'</p>';
$a+=1;
} else {
echo '<p>'.$a.' [<a style="color:red;"> erro </a>] '.$to.'</p>';
$a+=1;
}
}
}
fclose($file);
}
and to make the wordpress wp_mail() work correctly I have this on my functions.php.
if (! function_exists('email_sender')){
add_action('phpmailer_init','email_sender');
function email_sender($mail){
$mail->SetFrom('[email protected]', 'Tiago');
$mail->Host = 'smtp-mail.outlook.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'STARTTLS';
$mail->Username = '[email protected]';
$mail->Password = '1234567';
$mail->IsSMTP();
}
}