blob: 3b771a0b64763594143d3650cf293bfaf6e902d4 [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
Andrey Andreev21c3c222014-12-04 12:10:00 +02009.. important:: The Email helper is DEPRECATED and is currently
10 only kept for backwards compatibility.
Derek Jones8ede1a22011-10-05 13:34:52 -050011
Derek Jonesc43dc1e2013-07-21 11:00:38 -070012.. contents::
13 :local:
14
15.. raw:: html
16
17 <div class="custom-index container"></div>
Andrey Andreev0898e232012-11-08 15:13:52 +020018
Derek Jones8ede1a22011-10-05 13:34:52 -050019Loading this Helper
20===================
21
22This helper is loaded using the following code::
23
24 $this->load->helper('email');
25
Derek Jonesc43dc1e2013-07-21 11:00:38 -070026Available Functions
27===================
28
Derek Jones8ede1a22011-10-05 13:34:52 -050029The following functions are available:
30
Derek Jones8ede1a22011-10-05 13:34:52 -050031
Derek Jonesb8c283a2013-07-19 16:02:53 -070032.. function:: valid_email($email)
Derek Jones8ede1a22011-10-05 13:34:52 -050033
Andrey Andreev3de130c2014-02-07 23:31:49 +020034 :param string $email: E-mail address
35 :returns: TRUE if a valid email is supplied, FALSE otherwise
36 :rtype: bool
Derek Jones8ede1a22011-10-05 13:34:52 -050037
Derek Jonesc43dc1e2013-07-21 11:00:38 -070038 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 Jones8ede1a22011-10-05 13:34:52 -050041
Derek Jonesc43dc1e2013-07-21 11:00:38 -070042 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -050043
Derek Jonesc43dc1e2013-07-21 11:00:38 -070044 if (valid_email('email@somesite.com'))
45 {
46 echo 'email is valid';
47 }
48 else
49 {
50 echo 'email is not valid';
51 }
Derek Jones8ede1a22011-10-05 13:34:52 -050052
Derek Jonesc43dc1e2013-07-21 11:00:38 -070053 .. note:: All that this function does is to use PHP's native ``filter_var()``::
Derek Jones8ede1a22011-10-05 13:34:52 -050054
Derek Jonesc43dc1e2013-07-21 11:00:38 -070055 (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
56
Derek Jonesb8c283a2013-07-19 16:02:53 -070057.. function:: send_email($recipient, $subject, $message)
Andrey Andreev0898e232012-11-08 15:13:52 +020058
59 :param string $recipient: E-mail address
60 :param string $subject: Mail subject
61 :param string $message: Message body
Andrey Andreev3de130c2014-02-07 23:31:49 +020062 :returns: TRUE if the mail was successfully sent, FALSE in case of an error
63 :rtype: bool
Andrey Andreev0898e232012-11-08 15:13:52 +020064
Derek Jonesc43dc1e2013-07-21 11:00:38 -070065 Sends an email using PHP's native `mail() <http://www.php.net/function.mail>`_
66 function.
Andrey Andreev0898e232012-11-08 15:13:52 +020067
Derek Jonesc43dc1e2013-07-21 11:00:38 -070068 .. note:: All that this function does is to use PHP's native ``mail``
Andrey Andreev0898e232012-11-08 15:13:52 +020069
Derek Jonesc43dc1e2013-07-21 11:00:38 -070070 ::
71
72 mail($recipient, $subject, $message);
73
74 For a more robust email solution, see CodeIgniter's :doc:`Email Library
Andrey Andreev3de130c2014-02-07 23:31:49 +020075 <../libraries/email>`.