如何将附件从服务器添加到phpmailer

如何将附件从服务器添加到phpmailer,php,css,email,phpmailer,Php,Css,Email,Phpmailer,我正在尝试使用PHPmailer将文件附加到电子邮件中,我使用以下代码附加文件: $countfiles = count($file_paths); for($x = 0; $x < $countfiles;$x++) { $mail->AddAttachment($file_paths['details'][$x]); } $countfiles=count($file\u路径); 对于($x=0;$xAddAttachment($file

我正在尝试使用PHPmailer将文件附加到电子邮件中,我使用以下代码附加文件:

    $countfiles = count($file_paths);
    for($x = 0; $x < $countfiles;$x++)
    {
    $mail->AddAttachment($file_paths['details'][$x]);
    }
$countfiles=count($file\u路径);
对于($x=0;$x<$countfiles;$x++)
{
$mail->AddAttachment($file_路径['details'][$x]);
}
其中变量$file_paths['details'][$x]的值为:

/home5/aserver/public_html/website/style.css


但由于某些原因,它没有附加到邮件,邮件确实会发送到电子邮件。

您确定路径正确吗?您使用的是PHP文件所在的路径吗?@HenkdeJager是的,我非常确定,因为我使用了scandir函数,因此可以获取文件路径,然后将其保存在文件路径数组中。我刚刚更改了示例文件路径中的名称。