PHP 在 mailgun 中发送多个文件附件

PHP sending Mutliple Files attachment in mailgun

我正在尝试使用 mailgun 发送电子邮件并在正文消息中发送 url- 以上传用户文件夹中的文件...问题是我不知道如何捕获目录中的所有文件并显示是否喜欢链接(下载).. 这是我尝试用代码做的事情:

$uploadsDir = 'https://lionbg.net/careers-test/upload'.$folderName.'/';
$first_char = mb_substr($jsonDecode["firstName"], 0, 1);
$directory = "upload/".$folderName."";
$filesInFolder = glob($directory . "/*.jpg");
$files = array();
foreach($filesInFolder as $filename){
   //Simply print them out onto the screen.
   //$files = "<a href='".$uploadsDir.$filename"' target='_blank'>".$filename.'</a>';
   $result = array_merge($result, $filename);
}
$mg->sendMessage($domain, array(
  'from'    => 'from-email@gmail.com',
  'to'      => 'to@gmail.com',
  'subject' => 'New applicant',
  'text'    => ''.$result.''
));

不太确定你在问什么,但也许吧。这是一个精简版。生成的 HTML 只是指向目录中文件的链接列表:

<?
$protocol = "http://" ;
define('DOMAIN', $protocol . $_SERVER['SERVER_NAME'] . '/' );
$directory = "upload";

array_map('files', glob($directory . "/*.jpg"));

function files($images) {
echo '<li><a href ="' . DOMAIN . $images . '" target="_blank">' .   DOMAIN . $images . '</a></li>';
}

?>