Php Wordpress中的电子邮件附件

Php Wordpress中的电子邮件附件,php,wordpress,Php,Wordpress,我正在尝试使用在电子邮件中附加附件 $attachments = array("http://localhost/sitename/wp-content/plugins/plugin_name/uploads/Bluehills_10.jpg"); $headers = "From: $from <$from>" . "\r\n"; $headers .= "Disposition-Notification-To: $from\r\n"; $mail_sent =

我正在尝试使用在电子邮件中附加附件

 $attachments = array("http://localhost/sitename/wp-content/plugins/plugin_name/uploads/Bluehills_10.jpg");
   $headers = "From: $from <$from>" . "\r\n";
   $headers .= "Disposition-Notification-To: $from\r\n";
   $mail_sent = wp_mail("$to", "$subject", "$msg", $headers, $attachments );
$attachments=数组(“http://localhost/sitename/wp-content/plugins/plugin_name/uploads/Bluehills_10.jpg");
$headers=“From:$From”。“\r\n”;
$headers.=“处置通知到:$from\r\n”;
$mail\u sent=wp\u mail($to“,$subject“,$msg“,$headers,$attachments);
使用此代码,我可以将电子邮件发送到正确的位置,但附件不会随电子邮件一起发送

谁能告诉我原因是什么

另外,我以后想发送多个文件作为附件。但是这些文件不是zip格式的


提前感谢。

您已经将
url
用作
文件/附件
路径,但您应该使用计算机路径,您有以下内容:

// A url (should be a path of your server)
array("http://localhost/sitename/wp-content/plugins/plugin_name/uploads/Bluehills_10.jpg");

但是,您应该使用服务器的路径,它可以是相对路径,如
/uploads/images/photo1.jpg

谢谢。。我必须给出服务器的路径,而不是http url。很高兴这有帮助:-)