I am trying to send a mail with attachment, but failed repeatedly. However without attachment able to send mail. Below is my function.

```
public function sendmail($jid,$eid)
        {           
            $empdata = $this->search_m->eid($eid);
            $user = $this->session->userdata('userid');
            $jsdata = $this->search_m->jid($user);

            foreach($empdata->result() as $rows)
            {
                $empmail = $rows->email;                
            }

            foreach($jsdata->result() as $row)
            {
                $jsres = $row->resume;          
            }

             $file = "uploads/".$jsres;

            $this->load->library('email');
            //$this->email->clear();
            $config['charset'] = 'iso-8859-1';
            $config['wordwrap'] = TRUE; 

            $config['protocol'] = 'mail';
            $config['mailpath'] = '/usr/sbin/sendmail';     
            $config['smtp_port']=587;
            $config['smtp_host'] = 'smtp.gmail.com';
            $config['smtp_user'] = 'mail@gmail.com';
            $config['smtp_pass'] = 'password';
            $config['validate'] = TRUE;
            $this->email->initialize($config);          

            $this->email->from( 'hr@virtu.com','Gowtham');
            $this->email->to('gorodda@gmail.com');          
            $this->email->subject('Testing Email');
            $this->email->message('I applied to ur job');
            $this->email->attach($file);
            $this->email->send();

            if(!$this->email->send())
                {
                    echo " mail not send";

                }

            }

```

Where I am going wrong?