title: Multiple file Attachment and sending mail using Yii2
body: <p>Here i like to explain my problem clearly</p>
  
  <blockquote>
    <p>Am able to upload multiple file, but the problem am not getting the
    attached files in my mail, only one attachment alone am receiving, in
    server all files getting saved</p>
  </blockquote>
  
  <pre><code>$model-&gt;attachment = UploadedFile::getInstances($model, 'attachment');
  $files = '';
  
  if ( $model-&gt;attachment )
  {
      foreach ($model-&gt;attachment as $file) 
      {
          $file-&gt;saveAs('emailattachments/' .$file-&gt;baseName. '.' . $file-&gt;extension);
          $files = 'emailattachments/' .$file-&gt;baseName. '.' . $file-&gt;extension;
          $model-&gt;attachment = $files;
      }
  
  }
  if( $model-&gt;attachment )
  {
      $value = Yii::$app-&gt;mailer-&gt;compose()
      -&gt;setFrom([ Yii::$app-&gt;user-&gt;identity-&gt;email =&gt; 'Sample Mail'])
      -&gt;setTo($model-&gt;email)
      -&gt;setSubject($model-&gt;subject)
      -&gt;setHtmlBody($model-&gt;content)
      -&gt;attach($model-&gt;attachment)
      -&gt;send();
  }
  </code></pre>
  
  <p>Am upload multiple files but while sending mail, only one attachment itself receiveing. 
  How can i sort out this?</p>