お世話になっております。
共有フォルダにあるファイルをメールに添付する処理を作成しています。
パスをブラウザで開くと正常に開くことを確認しています。
ですが、attachにファイルのパスをを指定すると「Unable to open file for reading 」とエラーが出てしまいます。
attachを書かなければ正常にメールが送られます。
エラー内容について調べたのですが情報がなかったので質問させていただきました。
よろしくお願いします。
php
1public function make_mail(Request $request){ 2 $username = $request->input('name'); 3 $file = $request->input('testfile'); 4 $filepath = "\\192.××××××××\sample\$username"; 5 6 $pdf = $filepath.'\'.$file; 7 8 $this->sendMailTo_w($pdf); 9 10 return view('admin::sample_index'); 11 } 12 13private function sendMailTo_w($pdf){ 14 15 $to = 'sample@gmail.com'; 16 $cc = ''; 17 $bcc = ''; 18 $fromAddress = 'sample@gmail.com'; 19 $fromName = 'AAA'; 20 $subject = 'test'; 21 22 $email = [ 23 'to' => $to, 24 'cc' => $cc, 25 'bcc' => $bcc, 26 'from_address' => $fromAddress, 27 'from_name' => $fromName, 28 'subject' => $subject, 29 'attach' => $pdf 30 ]; 31 32 \Mail::send('admin::mail_temp', compact('email'), function($message) use ($email) { 33 34 if (is_array($email['to'])) { 35 $toArray = $email['to']; 36 } else { 37 $toArray = [$email['to']]; 38 } 39 foreach ($toArray as $key => $value) { 40 $message->to($value); 41 } 42 43 $message->subject($email['subject']); 44 45 if ($email['from_address']) { 46 $message->from($email['from_address'], $email['from_name']); 47 } 48 49 if ($email['cc']) { 50 $message->cc($email['cc']); 51 } 52 53 if ($email['bcc']) { 54 $message->bcc($email['bcc']); 55 } 56 57 if (array_key_exists('attach', $email) && $email['attach']) { 58 $message->attach($email['attach']); 59 } 60 }); 61 }

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/26 05:44
2018/03/26 05:46
2018/03/26 05:53
2018/03/26 05:58
2018/03/26 06:01 編集
2018/03/26 06:01
2018/03/26 06:05
2018/03/26 06:08
2018/03/26 06:11
2018/03/26 06:16
2018/03/26 06:22
2018/03/26 06:31
2018/03/26 06:33
2018/03/26 08:43