Van1310
4 months ago

mail file attachment in laravel

Posted 4 months ago by Van1310

any suggest how to mail with attachment

error => Swift_IoException in FileByteStream.php line 144:

Unable to open file for reading [TZSGVXjIhm6K45D3owlzoDngoieEpG.jpg]

$files = Input::file('attach');

    $picName = str_random(30) . '.' . $files->getClientOriginalExtension();

    $files->move(base_path() . '/public/email/', $picName);

    $email=new Email(array(
       
    'email'=>$request->get('email'),
        
    'subject'=>$request->get('subject'),
        
    'message'=>$request->get('message'),
        
    'attach'=>$picName,                     
    
));

\Mail::send('email.paymentmail', ["name" => "demo"], function($message) use($email)
        
{              
            
    $message->to($email->email)->subject($email->subject);
            
    $message->setbody($email->message);
            
    $message->attach($email->attach);                                        
        
});

Please sign in or create an account to participate in this conversation.