对于那些有相同问题的人,这是我的inteire代码,我必须将img标记放在主题正文标记内,而且一旦我使用$\\u POST,链接就不起作用了,我就使用了一个单词;[图像M]”;替换为img标签和上传的链接。
<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);
}
为了使wordpress wp\\u mail()正常工作,我在函数中使用了这个。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();
}
}