我尝试使用laravel smtp发送电子邮件,
Mail::send('mail', $data, function($message) use ($request){
$message->to($request->input('email'), 'Than Htut')->subject
($request->input('subject'));
$message->attach($request->input('resume'));
$message->from('myemail@gmail.com','My Name');
});
echo "HTML Email Sent. Check your inbox.";
问题显示如下
Swift_IoException 无法打开文件进行阅读
但是如果我像这样使用attachData
Mail::send('mail', $data, function($message) use ($request){
$message->to($request->input('email'), 'Than Htut')->subject
($request->input('subject'));
$message->attachData($request->input('resume'), "haha.pdf");
$message->from('myemail@gmail.com','My Name');
});
echo "HTML Email Sent. Check your inbox.";
<form class="uk-form-stacked" action="{{ url('jobseekers/send') }}" method="post" id="cv_mail_data">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="cv_no" value="{{ $jobseekers->id }}">
<input type="text" placeholder="To" name="email" class="md-input" multiple>
<input type="text" placeholder="To" name="subject" class="md-input" multiple>
<input type="file" name="resume" accept="application/pdf,application/vnd.ms-excel" />
<div class="uk-grid" data-uk-grid-margin>
<div class="uk-width-medium-1-1 parsley-row">
<textarea id="wysiwyg_tinymce" name="cover_letter" cols="30"
rows="20"></textarea>
</div>
</div>
<button type="submit" class="btn btn-primary">
Create
</button>
请指导我,谢谢。
答案 0 :(得分:1)
首先,您表单中的enctype="multipart/form-data"
属性在哪里?
第二,要在laravel上检索文件,请使用文件方法$request->file('your-file');
。