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 | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 33 | :param string $email: E-mail address |
| 34 | :returns: TRUE if a valid email is supplied, FALSE otherwise |
| 35 | :rtype: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 36 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 37 | Checks if the input is a correctly formatted e-mail address. Note that is |
| 38 | doesn't actually prove that the address will be able recieve mail, but |
| 39 | simply that it is a validly formed address. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 40 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 41 | Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 42 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 43 | if (valid_email('email@somesite.com')) |
| 44 | { |
| 45 | echo 'email is valid'; |
| 46 | } |
| 47 | else |
| 48 | { |
| 49 | echo 'email is not valid'; |
| 50 | } |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 51 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 52 | .. 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] | 53 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 54 | (bool) filter_var($email, FILTER_VALIDATE_EMAIL); |
| 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 |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 61 | :returns: TRUE if the mail was successfully sent, FALSE in case of an error |
| 62 | :rtype: bool |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 63 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 64 | Sends an email using PHP's native `mail() <http://www.php.net/function.mail>`_ |
| 65 | function. |
Andrey Andreev | 0898e23 | 2012-11-08 15:13:52 +0200 | [diff] [blame] | 66 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 67 | .. 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] | 68 | |
Derek Jones | c43dc1e | 2013-07-21 11:00:38 -0700 | [diff] [blame] | 69 | :: |
| 70 | |
| 71 | mail($recipient, $subject, $message); |
| 72 | |
| 73 | For a more robust email solution, see CodeIgniter's :doc:`Email Library |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 74 | <../libraries/email>`. |