Created
November 10, 2013 20:19
-
-
Save abdullahbutt/7403396 to your computer and use it in GitHub Desktop.
CI Email attachments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Send Email Attachments without Hassles | |
| Sending emails is a complex business. CI's code for doing it looks easy to follow: | |
| $this->load->library('email'); | |
| $this->email->from('your@your-site.com', 'Your Name'); | |
| $this->email->subject('Email Test'); | |
| $this->email->message('Testing the email class.'); | |
| $this->email->send(); | |
| There are a number of issues involved in sending emails: setting word-wrapping (and escaping it so long URLs don't get wrapped and broken up) for example, or sending attachments. The standard PHP functions can get quite complex here, and the result is that many code writers are tempted to avoid using these functions if they possibly can. | |
| CI's email class makes it simple to send an attachment. You write: | |
| $this->email->attach('/path/to/photo1.jpg'); | |
| CI does the rest. Working behind the scenes, for example, is a function that sorts out MIME types for nearly hundred different types of attachment. So it knows that | |
| your photo, photo1.jpg,is an image/jpeg' MIME type. It remembers to generate boundary delimiters in the right places around your attachments. It takes care of wrapping your text, and it allows you to easily mark out chunks of text you don't want wrapped. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment