Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ############ |
| 2 | Email Helper |
| 3 | ############ |
| 4 | |
| 5 | The Email Helper provides some assistive functions for working with |
| 6 | Email. For a more robust email solution, see CodeIgniter's :doc:`Email |
| 7 | Class <../libraries/email>`. |
| 8 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 9 | .. important:: The Email helper is **deprecated**. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 10 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 11 | .. contents:: |
| 12 | :local: |
| 13 | |
| 14 | .. raw:: html |
| 15 | |
| 16 | <div class="custom-index container"></div> |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 17 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 18 | Loading this Helper |
| 19 | =================== |
| 20 | |
| 21 | This helper is loaded using the following code:: |
| 22 | |
| 23 | $this->load->helper('email'); |
| 24 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 25 | Available Functions |
| 26 | =================== |
| 27 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 28 | The following functions are available: |
| 29 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 30 | |
Derek Jones | b8c283a | 2013-07-19 16:02:53 -0700 | [diff] [blame] | 31 | .. function:: valid_email($email) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 32 | |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 33 | :param string $email: Email address |
| 34 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 35 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 36 | Checks if the input is a correctly formatted e-mail address. Note that is |
| 37 | doesn't actually prove that the address will be able recieve mail, but |
| 38 | simply that it is a validly formed address. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 39 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 40 | Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 41 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 42 | if (valid_email('email@somesite.com')) |
| 43 | { |
| 44 | echo 'email is valid'; |
| 45 | } |
| 46 | else |
| 47 | { |
| 48 | echo 'email is not valid'; |
| 49 | } |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 50 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 51 | .. note:: All that this function does is to use PHP's native ``filter_var()``:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 52 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 53 | (bool) filter_var($email, FILTER_VALIDATE_EMAIL); |
| 54 | |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 55 | |
Derek Jones | b8c283a | 2013-07-19 16:02:53 -0700 | [diff] [blame] | 56 | .. function:: send_email($recipient, $subject, $message) |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 57 | |
| 58 | :param string $recipient: E-mail address |
| 59 | :param string $subject: Mail subject |
| 60 | :param string $message: Message body |
| 61 | :returns: bool |
| 62 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 63 | Sends an email using PHP's native `mail() <http://www.php.net/function.mail>`_ |
| 64 | function. |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 65 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 66 | .. note:: All that this function does is to use PHP's native ``mail`` |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 67 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 68 | :: |
| 69 | |
| 70 | mail($recipient, $subject, $message); |
| 71 | |
| 72 | For a more robust email solution, see CodeIgniter's :doc:`Email Library |
| 73 | <../libraries/email>`. |