1
如何發送laravel中的多個附件郵件?Laravel Mail ::發送多個附件
這是我laravel控制器:
public function send_approve_mail($to, $subj, $tmp, $path) {
$_POST['subj'] = $subj;
$_POST['to'] = $to;
foreach ($path as $key => $value) {
$path[$key] = '../public/assets/fax/extra/' . $value;
}
$_POST['attach'] = $path;
$msg = "test message here";
$data_mail = Mail::send($tmp, array('msg' => $msg), function($message) {
$message->from('[email protected]', $_POST['subj']);
$message->to($_POST['to'])->subject($_POST['subj']);
$message->attach($_POST['attach']);
}, true);
Help::send_mail($data_mail, array($_POST['to']), array('[email protected]'));
}
所有附件都在陣$path
可用。
它顯示錯誤basename() expects parameter 1 to be string, array given
。
但是,當我使用$_POST['attach'] = $path[0];
而不是$_POST['attach'] = $path;
時,郵件只收到一個附件。
它可以正常使用您的建議...謝謝 – 2014-09-18 18:15:55
$ message-> attach($ path [i]);應該是$ message-> attach($ path [$ i]); – 2016-04-27 12:53:54