我目前在我的应用程序中使用Laravel和sendgrid。
我希望能够接收带有附件的电子邮件并将其存储在服务器上。但这里的问题是,我该怎么办呢?我目前有一个代码编写,但该代码根本不起作用。我可以收到电子邮件,但它不会存储附件。有人可以帮助我吗?
以下是我目前的代码:
public function ReceiveMail(Request $request)
{
//inserting the email into the database
// getting all of the post data
$files = $request->get('attachments');
// Making counting of uploaded images
$file_count = count($files);
//var_dump($files);
//die;
if($file_count > 0){
foreach($files as $key=>$value) {
$attachment[] = $value;
$destinationPath = 'public/uploads/pictures/rallypodium/website/mail/attachments/';
$extension = $attachment->getClientOriginalExtension();
$filename = $attachment->getClientOriginalName();
$uploadSuccess = $attachment->move($destinationPath, $filename.$extension);
}
}
return '250';
}