2017-08-29 51 views
0

以下是我在wp_mail中的正文内容。图像未送入内嵌电子邮件正文

$message = 
     "<tr> 
      <td> 
       Attach File: 
      </td> 
      <td> 
       <img src='".plugin_dir_url(__FILE__)."uploadedfiles/".$ent['attachedfile']."' 
       width='200' height='200'> 
      </td> 
     </tr>"; 

$attachments[] =dirname(__FILE__)."/uploadedfiles/".$ent['attachedfile']; 

$headers = 'From: Company <'.$from.'>' . "\r\n"; 
wp_mail($to,$subject,$message,$headers,$attachments);  

问题是,在邮件中,我得到的图像作为附件,但没有显示在正文中。根据我的代码,它应该显示在那里。

如何在wp_email body中添加图像?

+0

相关https://开头计算器。 COM /问题/ 15646187 /显示直列图像附件与 - WP-邮件 –

回答

0

好了,问题是,你正在使用plugin_dir_url首次目录名第二次,只是改变它像这样,它可能工作:

$imgURL = dirname(__FILE__)."uploadedfiles/".$ent['attachedfile']; 
$message = "<tr> 
      <td> 
       Attach File: 
      </td> 
      <td><img src='".$imgURL."' width='200' height='200'> 

      </td> 
     </tr>"; 

$headers = 'From: Company <'.$from.'>' . "\r\n"; 
wp_mail($to,$subject,$message,$headers,$imgURL); 
相关问题