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