1 | <?php |
||
20 | class Email { |
||
21 | /** |
||
22 | * Who to send to |
||
23 | * @var array |
||
24 | */ |
||
25 | private $mTo = array(); |
||
26 | |||
27 | /** |
||
28 | * Who the message is from |
||
29 | * @var array |
||
30 | */ |
||
31 | private $mFrom = array(); |
||
32 | |||
33 | /** |
||
34 | * Subject |
||
35 | * @var string |
||
36 | */ |
||
37 | private $mSubject; |
||
38 | |||
39 | /** |
||
40 | * Message to send |
||
41 | * @var string |
||
42 | */ |
||
43 | private $mMessage; |
||
44 | |||
45 | /** |
||
46 | * CC field |
||
47 | * @var array |
||
48 | */ |
||
49 | private $mCC = array(); |
||
50 | |||
51 | /** |
||
52 | * BCC field |
||
53 | * @var array |
||
54 | */ |
||
55 | private $mBCC = array(); |
||
56 | |||
57 | /** |
||
58 | * Reply-to field |
||
59 | * @var array |
||
60 | */ |
||
61 | private $mRT = array(); |
||
62 | |||
63 | /** |
||
64 | * Construct function, adds the From: field, subject, and message |
||
65 | * @param string $fromEmail Email address of sender |
||
66 | * @param string $fromName Name of sender. |
||
67 | * @param string $subject Subject of email |
||
68 | * @param string $message Message to send |
||
69 | * @throws DependencyError |
||
70 | */ |
||
71 | function __construct( $fromEmail, $fromName, $subject, $message ) { |
||
85 | |||
86 | /** |
||
87 | * Adds another email to the To: field. |
||
88 | * @param string $toEmail Email address of recipient |
||
89 | * @param string $toName Name of recipient. Default null |
||
90 | */ |
||
91 | public function addTarget( $toEmail, $toName = null ) { |
||
98 | |||
99 | /** |
||
100 | * Adds another email to the CC: field. |
||
101 | * @param string $ccEmail Email address of cc |
||
102 | * @param string $ccName Name of cc. Default null |
||
103 | */ |
||
104 | public function addCC( $ccEmail, $ccName = null ) { |
||
111 | |||
112 | /** |
||
113 | * Adds another email to the BCC: field. |
||
114 | * @param string $bccEmail Email address of bcc |
||
115 | * @param string $bccName Name of bcc. Default null |
||
116 | */ |
||
117 | public function addBCC( $bccEmail, $bccName = null ) { |
||
124 | |||
125 | /** |
||
126 | * Adds another email to the Reply-to: field. |
||
127 | * @param string $rtEmail Email address to reply to |
||
128 | * @param string $rtName Name to reply to. Default null |
||
129 | */ |
||
130 | public function addReplyTo( $rtEmail, $rtName = null ) { |
||
137 | |||
138 | /** |
||
139 | * Sends the email. |
||
140 | */ |
||
141 | public function send() { |
||
212 | } |
||
213 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.