1 | <?php |
||
11 | class Mail |
||
12 | { |
||
13 | /** @var mixed variable to collect errors */ |
||
14 | private $error; |
||
15 | |||
16 | /** |
||
17 | * Try to send a mail by using PHP's native mail() function. |
||
18 | * Please note that not PHP itself will send a mail, it's just a wrapper for Linux's sendmail or other mail tools |
||
19 | * |
||
20 | * Good guideline on how to send mails natively with mail(): |
||
21 | * @see http://stackoverflow.com/a/24644450/1114320 |
||
22 | * @see http://www.php.net/manual/en/function.mail.php |
||
23 | */ |
||
24 | public function sendMailWithNativeMailFunction() |
||
29 | |||
30 | /** |
||
31 | * Try to send a mail by using SwiftMailer. |
||
32 | * Make sure you have loaded SwiftMailer via Composer. |
||
33 | * |
||
34 | * @return bool |
||
35 | */ |
||
36 | public function sendMailWithSwiftMailer() |
||
41 | |||
42 | /** |
||
43 | * Try to send a mail by using PHPMailer. |
||
44 | * Make sure you have loaded PHPMailer via Composer. |
||
45 | * Depending on your EMAIL_USE_SMTP setting this will work via SMTP credentials or via native mail() |
||
46 | * |
||
47 | * @param $user_email |
||
48 | * @param $from_email |
||
49 | * @param $from_name |
||
50 | * @param $subject |
||
51 | * @param $body |
||
52 | * |
||
53 | * @return bool |
||
54 | * @throws Exception |
||
55 | * @throws phpmailerException |
||
56 | */ |
||
57 | public function sendMailWithPHPMailer($user_email, $from_email, $from_name, $subject, $body) |
||
113 | |||
114 | /** |
||
115 | * The main mail sending method, this simply calls a certain mail sending method depending on which mail provider |
||
116 | * you've selected in the application's config. |
||
117 | * |
||
118 | * @param $user_email string email |
||
119 | * @param $from_email string sender's email |
||
120 | * @param $from_name string sender's name |
||
121 | * @param $subject string subject |
||
122 | * @param $body string full mail body text |
||
123 | * @return bool the success status of the according mail sending method |
||
124 | */ |
||
125 | public function sendMail($user_email, $from_email, $from_name, $subject, $body) |
||
143 | |||
144 | /** |
||
145 | * The different mail sending methods write errors to the error property $this->error, |
||
146 | * this method simply returns this error / error array. |
||
147 | * |
||
148 | * @return mixed |
||
149 | */ |
||
150 | public function getError() |
||
154 | } |
||
155 |