Inside of mail send function you cannot use Input:: facade, it's not available there - for that you wrote use $input, so play with $input variable there.
Nov 15, 2016
9
Level 1
Send files via email from register form
This is how I can send multiple files via email directly from a form without the need of uploading the file:
$input = Input::all();
$data = ['level' => 'register',
'introLines' => ['Ein neuer Benutzer hat sich registriert und wartet auf die Freischaltung', 'Im Anhang befinden sich vom Benutzer übermittelte Dokumente.'],
'actionText' => 'Benutzer verwalten',
'actionUrl' => Config::get('constants.bywood_url') . '/admin/user',
'outroLines' => ['Klicken Sie hier um die Benutzer zu verwalten']];
Mail::send('vendor.notifications.email', $data, function($message) use ($input)
{
$message->to(Config::get('constants.bywood_mail'));
$message->subject('Ein neuer Benutzer hat sich registriert');
$message->from(Config::get('constants.bywood_mail'));
if(Input::file('files')){
foreach(Input::file('files') as $file) {
$message->attach( $file->getRealPath(), array(
'as' => $file->getClientOriginalName(),
'mime' => $file->getMimeType())
);
}
}
});
The thing is that I need to do this while registering a user. As I am using the build in authentication mechanism the RegisterController provides a create() method and somehow I cannot access the Input::File variable (it is null).
Any idea on how to solve this?
Please or to participate in this conversation.