blob: fe3ccdda1cab3b8f547ae8d40b4d510d08c62370 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001############
2Email Helper
3############
4
5The Email Helper provides some assistive functions for working with
6Email. For a more robust email solution, see CodeIgniter's :doc:`Email
7Class <../libraries/email>`.
8
Derek Jonesc43dc1e2013-07-21 11:00:38 -07009.. important:: The Email helper is **deprecated**.
Derek Jones8ede1a22011-10-05 13:34:52 -050010
Derek Jonesc43dc1e2013-07-21 11:00:38 -070011.. contents::
12 :local:
13
14.. raw:: html
15
16 <div class="custom-index container"></div>
Andrey Andreev0898e232012-11-08 15:13:52 +020017
Derek Jones8ede1a22011-10-05 13:34:52 -050018Loading this Helper
19===================
20
21This helper is loaded using the following code::
22
23 $this->load->helper('email');
24
Derek Jonesc43dc1e2013-07-21 11:00:38 -070025Available Functions
26===================
27
Derek Jones8ede1a22011-10-05 13:34:52 -050028The following functions are available:
29
Derek Jones8ede1a22011-10-05 13:34:52 -050030
Derek Jonesb8c283a2013-07-19 16:02:53 -070031.. function:: valid_email($email)
Derek Jones8ede1a22011-10-05 13:34:52 -050032
Andrey Andreev0898e232012-11-08 15:13:52 +020033 :param string $email: Email address
34 :returns: bool
Derek Jones8ede1a22011-10-05 13:34:52 -050035
Derek Jonesc43dc1e2013-07-21 11:00:38 -070036 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 Jones8ede1a22011-10-05 13:34:52 -050039
Derek Jonesc43dc1e2013-07-21 11:00:38 -070040 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -050041
Derek Jonesc43dc1e2013-07-21 11:00:38 -070042 if (valid_email('email@somesite.com'))
43 {
44 echo 'email is valid';
45 }
46 else
47 {
48 echo 'email is not valid';
49 }
Derek Jones8ede1a22011-10-05 13:34:52 -050050
Derek Jonesc43dc1e2013-07-21 11:00:38 -070051 .. note:: All that this function does is to use PHP's native ``filter_var()``::
Derek Jones8ede1a22011-10-05 13:34:52 -050052
Derek Jonesc43dc1e2013-07-21 11:00:38 -070053 (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
54
Andrey Andreev0898e232012-11-08 15:13:52 +020055
Derek Jonesb8c283a2013-07-19 16:02:53 -070056.. function:: send_email($recipient, $subject, $message)
Andrey Andreev0898e232012-11-08 15:13:52 +020057
58 :param string $recipient: E-mail address
59 :param string $subject: Mail subject
60 :param string $message: Message body
61 :returns: bool
62
Derek Jonesc43dc1e2013-07-21 11:00:38 -070063 Sends an email using PHP's native `mail() <http://www.php.net/function.mail>`_
64 function.
Andrey Andreev0898e232012-11-08 15:13:52 +020065
Derek Jonesc43dc1e2013-07-21 11:00:38 -070066 .. note:: All that this function does is to use PHP's native ``mail``
Andrey Andreev0898e232012-11-08 15:13:52 +020067
Derek Jonesc43dc1e2013-07-21 11:00:38 -070068 ::
69
70 mail($recipient, $subject, $message);
71
72 For a more robust email solution, see CodeIgniter's :doc:`Email Library
73 <../libraries/email>`.