PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.45
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.45
2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 1.45 All 41 releases
fluent-boards / app / Services / Libs / Mailer.php

Mailer.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.45, at app/Services/Libs/Mailer.php

111 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\App\Services\Libs;
4
5 class Mailer
6 {
7 private $subject = '';
8
9 private $body = '';
10
11 private $to = '';
12
13 private $from = '';
14
15 private $cc = [];
16
17 private $bcc = [];
18
19 private $replyTo = '';
20
21 private $isHtml = true;
22
23 public function __construct($to = '', $subject = '', $body = '')
24 {
25 $this->to = $to;
26 $this->subject = $subject;
27 $this->body = $body;
28 }
29
30 public function setSubject($subject)
31 {
32 $this->subject = $subject;
33 return $this;
34 }
35
36 public function setBody($body)
37 {
38 $this->body = $body;
39 return $this;
40 }
41
42 public function to($to)
43 {
44 $this->to = $to;
45 return $this;
46 }
47
48 public function setIsHtml($isHtml)
49 {
50 $this->isHtml = $isHtml;
51 return $this;
52 }
53
54 public function setFrom($from)
55 {
56 $this->from = $from;
57 return $this;
58 }
59
60 public function addCC($cc)
61 {
62 $this->cc[] = $cc;
63 return $this;
64 }
65
66 public function addBCC($bcc)
67 {
68 $this->bcc[] = $bcc;
69 return $this;
70 }
71
72 public function setReplyTo($replyTo)
73 {
74 $this->replyTo = $replyTo;
75 return $this;
76 }
77
78 public function send()
79 {
80 if (!$this->to && !$this->cc && !$this->bcc) {
81 return false;
82 }
83
84 $headers = [];
85
86 if ($this->isHtml) {
87 $headers[] = 'Content-Type: text/html; charset=UTF-8';
88 } else {
89 $headers[] = 'Content-Type: text/plain; charset=UTF-8';
90 }
91
92 if ($this->from) {
93 $headers[] = 'From: ' . $this->from;
94 }
95
96 if ($this->cc) {
97 $headers[] = 'Cc: ' . implode(',', $this->cc);
98 }
99
100 if ($this->bcc) {
101 $headers[] = 'Bcc: ' . implode(',', $this->bcc);
102 }
103
104 if ($this->replyTo) {
105 $headers[] = 'Reply-To: ' . $this->replyTo;
106 }
107
108 return wp_mail($this->to, $this->subject, $this->body, $headers);
109 }
110 }
111