CI_Email::attach()

attach($filename[, $disposition = ''[, $newname = NULL[, $mime = '']]])

Parameters:
  • $filename (string) – File name
  • $disposition (string) – ‘disposition’ of the attachment. Most email clients make their own decision regardless of the MIME specification used here. https://www.iana.org/assignments/cont-disp/cont-disp.xhtml
  • $newname (string) – Custom file name to use in the e-mail
  • $mime (string) – MIME type to use (useful for buffered data)
Returns:

CI_Email instance (method chaining)

Return type:

CI_Email

Enables you to send an attachment. Put the file path/name in the first parameter. For multiple attachments use the method multiple times. For example:

$this->email->attach('/path/to/photo1.jpg');
$this->email->attach('/path/to/photo2.jpg');
$this->email->attach('/path/to/photo3.jpg');

To use the default disposition (attachment), leave the second parameter blank, otherwise use a custom disposition:

$this->email->attach('image.jpg', 'inline');

You can also use a URL:

$this->email->attach('http://example.com/filename.pdf');

If you’d like to use a custom file name, you can use the third paramater:

$this->email->attach('filename.pdf', 'attachment', 'report.pdf');

If you need to use a buffer string instead of a real - physical - file you can use the first parameter as buffer, the third parameter as file name and the fourth parameter as mime-type:

$this->email->attach($buffer, 'attachment', 'report.pdf', 'application/pdf');
doc_CodeIgniter
2016-10-15 16:31:28
Comments
Leave a Comment

Please login to continue.