1 | <?php |
||
8 | class Mail |
||
|
|||
9 | { |
||
10 | /** @var mixed variable to collect errors */ |
||
11 | private $error; |
||
12 | |||
13 | /** |
||
14 | * Try to send a mail by using PHP's native mail() function. |
||
15 | * Please note that not PHP itself will send a mail, it's just a wrapper for Linux's sendmail or other mail tools |
||
16 | * |
||
17 | * Good guideline on how to send mails natively with mail(): |
||
18 | * @see http://stackoverflow.com/a/24644450/1114320 |
||
19 | * @see http://www.php.net/manual/en/function.mail.php |
||
20 | */ |
||
21 | public function sendMailWithNativeMailFunction() |
||
26 | |||
27 | /** |
||
28 | * Try to send a mail by using SwiftMailer. |
||
29 | * Make sure you have loaded SwiftMailer via Composer. |
||
30 | * |
||
31 | * @return bool |
||
32 | */ |
||
33 | public function sendMailWithSwiftMailer() |
||
38 | |||
39 | /** |
||
40 | * Try to send a mail by using PHPMailer. |
||
41 | * Make sure you have loaded PHPMailer via Composer. |
||
42 | * Depending on your EMAIL_USE_SMTP setting this will work via SMTP credentials or via native mail() |
||
43 | * |
||
44 | * @param $user_email |
||
45 | * @param $from_email |
||
46 | * @param $from_name |
||
47 | * @param $subject |
||
48 | * @param $body |
||
49 | * |
||
50 | * @return bool |
||
51 | * @throws Exception |
||
52 | * @throws phpmailerException |
||
53 | */ |
||
54 | public function sendMailWithPHPMailer($user_email, $from_email, $from_name, $subject, $body) |
||
110 | |||
111 | /** |
||
112 | * The main mail sending method, this simply calls a certain mail sending method depending on which mail provider |
||
113 | * you've selected in the application's config. |
||
114 | * |
||
115 | * @param $user_email string email |
||
116 | * @param $from_email string sender's email |
||
117 | * @param $from_name string sender's name |
||
118 | * @param $subject string subject |
||
119 | * @param $body string full mail body text |
||
120 | * @return bool the success status of the according mail sending method |
||
121 | */ |
||
122 | public function sendMail($user_email, $from_email, $from_name, $subject, $body) |
||
140 | |||
141 | /** |
||
142 | * The different mail sending methods write errors to the error property $this->error, |
||
143 | * this method simply returns this error / error array. |
||
144 | * |
||
145 | * @return mixed |
||
146 | */ |
||
147 | public function getError() |
||
151 | } |
||
152 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.