summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/helpers/email_helper.rst
blob: e0b2e4eaba6de96f2e704c152c1783a87b3db87e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
############
Email Helper
############

The Email Helper provides some assistive functions for working with
Email. For a more robust email solution, see CodeIgniter's :doc:`Email
Class <../libraries/email>`.

.. important:: The Email helper is DEPRECATED and is currently
	only kept for backwards compatibility.

.. contents::
  :local:

.. raw:: html

  <div class="custom-index container"></div>

Loading this Helper
===================

This helper is loaded using the following code::

	$this->load->helper('email');

Available Functions
===================

The following functions are available:


.. php:function:: valid_email($email)

	:param	string	$email: E-mail address
	:returns:	TRUE if a valid email is supplied, FALSE otherwise
	:rtype:	bool

	Checks if the input is a correctly formatted e-mail address. Note that it
	doesn't actually prove that the address will be able to receive mail, but
	simply that it is a validly formed address.

	Example::

		if (valid_email('email@somesite.com'))
		{
			echo 'email is valid';
		}
		else
		{
			echo 'email is not valid';
		}

	.. note:: All that this function does is to use PHP's native ``filter_var()``::

		(bool) filter_var($email, FILTER_VALIDATE_EMAIL);

.. php:function:: send_email($recipient, $subject, $message)

	:param	string	$recipient: E-mail address
	:param	string	$subject: Mail subject
	:param	string	$message: Message body
	:returns:	TRUE if the mail was successfully sent, FALSE in case of an error
	:rtype:	bool

	Sends an email using PHP's native `mail() <http://php.net/function.mail>`_
	function.

	.. note:: All that this function does is to use PHP's native ``mail``

		::

			mail($recipient, $subject, $message);

	For a more robust email solution, see CodeIgniter's :doc:`Email Library
	<../libraries/email>`.