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 | |
Andrey Andreev | 21c3c22 | 2014-12-04 12:10:00 +0200 | [diff] [blame] | 9 | .. important:: The Email helper is DEPRECATED and is currently |
| 10 | only kept for backwards compatibility. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 11 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 12 | .. contents:: |
| 13 | :local: |
| 14 | |
| 15 | .. raw:: html |
| 16 | |
| 17 | <div class="custom-index container"></div> |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 18 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 19 | Loading this Helper |
| 20 | =================== |
| 21 | |
| 22 | This helper is loaded using the following code:: |
| 23 | |
| 24 | $this->load->helper('email'); |
| 25 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 26 | Available Functions |
| 27 | =================== |
| 28 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 29 | The following functions are available: |
| 30 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 31 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 32 | .. php:function:: valid_email($email) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 33 | |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 34 | :param string $email: E-mail address |
| 35 | :returns: TRUE if a valid email is supplied, FALSE otherwise |
| 36 | :rtype: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 37 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 38 | Checks if the input is a correctly formatted e-mail address. Note that is |
| 39 | doesn't actually prove that the address will be able recieve mail, but |
| 40 | simply that it is a validly formed address. |
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 | Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 43 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 44 | if (valid_email('email@somesite.com')) |
| 45 | { |
| 46 | echo 'email is valid'; |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | echo 'email is not valid'; |
| 51 | } |
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 | .. 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] | 54 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 55 | (bool) filter_var($email, FILTER_VALIDATE_EMAIL); |
| 56 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 57 | .. php:function:: send_email($recipient, $subject, $message) |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 58 | |
| 59 | :param string $recipient: E-mail address |
| 60 | :param string $subject: Mail subject |
| 61 | :param string $message: Message body |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 62 | :returns: TRUE if the mail was successfully sent, FALSE in case of an error |
| 63 | :rtype: bool |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 64 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 65 | Sends an email using PHP's native `mail() <http://www.php.net/function.mail>`_ |
| 66 | function. |
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 | .. 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] | 69 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 70 | :: |
| 71 | |
| 72 | mail($recipient, $subject, $message); |
| 73 | |
| 74 | For a more robust email solution, see CodeIgniter's :doc:`Email Library |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 75 | <../libraries/email>`. |