blob: b665ce548ea3cf8af07c7795b7a131d9b83a3351 [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 Andreev3de130c2014-02-07 23:31:49 +020033 :param string $email: E-mail address
34 :returns: TRUE if a valid email is supplied, FALSE otherwise
35 :rtype: bool
Derek Jones8ede1a22011-10-05 13:34:52 -050036
Derek Jonesc43dc1e2013-07-21 11:00:38 -070037 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 Jones8ede1a22011-10-05 13:34:52 -050040
Derek Jonesc43dc1e2013-07-21 11:00:38 -070041 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -050042
Derek Jonesc43dc1e2013-07-21 11:00:38 -070043 if (valid_email('email@somesite.com'))
44 {
45 echo 'email is valid';
46 }
47 else
48 {
49 echo 'email is not valid';
50 }
Derek Jones8ede1a22011-10-05 13:34:52 -050051
Derek Jonesc43dc1e2013-07-21 11:00:38 -070052 .. note:: All that this function does is to use PHP's native ``filter_var()``::
Derek Jones8ede1a22011-10-05 13:34:52 -050053
Derek Jonesc43dc1e2013-07-21 11:00:38 -070054 (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
55
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
Andrey Andreev3de130c2014-02-07 23:31:49 +020061 :returns: TRUE if the mail was successfully sent, FALSE in case of an error
62 :rtype: bool
Andrey Andreev0898e232012-11-08 15:13:52 +020063
Derek Jonesc43dc1e2013-07-21 11:00:38 -070064 Sends an email using PHP's native `mail() <http://www.php.net/function.mail>`_
65 function.
Andrey Andreev0898e232012-11-08 15:13:52 +020066
Derek Jonesc43dc1e2013-07-21 11:00:38 -070067 .. note:: All that this function does is to use PHP's native ``mail``
Andrey Andreev0898e232012-11-08 15:13:52 +020068
Derek Jonesc43dc1e2013-07-21 11:00:38 -070069 ::
70
71 mail($recipient, $subject, $message);
72
73 For a more robust email solution, see CodeIgniter's :doc:`Email Library
Andrey Andreev3de130c2014-02-07 23:31:49 +020074 <../libraries/email>`.