• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Email attachment not working

I am using CI Email library for sending emails. But attachment is not working for me. I have tried to attach files using $this->email->attach() function. But it didn't worked.

Here is my function for sending email.
function send()
        $subject = 'testing subject';
        $message = 'testing';
        $from0 = '[email protected]';
        $from1 = 'Administrator';
        $config['protocol'] = 'smtp';
        $config['smtp_host'] = 'mydomain.com';
        $config['smtp_user'] = 'user';
        $config['smtp_pass'] = 'pass';
        $config['mailtype'] = 'html';
        $this->email->to('[email protected]');

        $path = "uploads/files/1.jpg";
        echo $this->email->print_debugger();
But I am getting an error like

Unable to open this attachment: uploads/files/1.jpg . I have tried with various paths like $_SERVER['DOCUMENT_ROOT'].'uploads/files/1.jpg' , './uploads/files/1.jpg' etc. But no one works for me. Even I have checked for permissions for upload folder. Its already set to rwx for all users. But still attachment doesn't works. Also when I try to send the mail with attachment mail body doesn't comes. As soon as I comment this line,the message body comes. I don't know what is the problem behind this. Please help me. Thanks in advance.

[eluser]Zeeshan Rasool[/eluser]
Did you check like that?use '.' before upload/files

$path = ".uploads/files/1.jpg";

[eluser]Thorpe Obazee[/eluser]
In case you upload the file before you send it, you can use the file upload, $this->upload->data() array.

Yes. I have checked with .uploads too but it didn't work. Also I have that file already available on server so it doesn't need to be uploaded...

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.