Combu Server  3.1.1
PHP API Documentation
Mail.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Combu;
4 
5 class Mail extends \PHPMailer {
6 
7  public $body;
8 
9  function __construct() {
10  parent::__construct();
11  $this->CharSet = 'UTF-8';
12  $this->XMailer = ' ';
13  $this->addCustomHeader("X-PHP-Script", " ");
14  $this->addCustomHeader("X-PHP-Filename", " ");
15  if (defined("EMAIL_SMTP") && EMAIL_SMTP === TRUE) {
16  $this->setSmtpConfig();
17  }
18  }
19 
20  private function setSmtpConfig() {
21  if (defined("EMAIL_SMTP_HOSTNAME") && !empty(EMAIL_SMTP_HOSTNAME)) {
22  $this->isSMTP();
23  $this->Host = EMAIL_SMTP_HOSTNAME;
24  $this->Hostname = EMAIL_SMTP_HOSTNAME;
25  if (defined("EMAIL_SMTP_PORT") && !empty(EMAIL_SMTP_PORT)) {
26  $this->Port = EMAIL_SMTP_PORT;
27  }
28  if (defined("EMAIL_SMTP_SECURE") && !empty(EMAIL_SMTP_SECURE)) {
29  $this->SMTPSecure = EMAIL_SMTP_SECURE;
30  }
31  if (defined("EMAIL_SMTP_USERNAME") && !empty(EMAIL_SMTP_USERNAME)) {
32  $this->SMTPAuth = TRUE;
33  $this->Username = EMAIL_SMTP_USERNAME;
34  $this->Password = (defined("EMAIL_SMTP_PASSWORD") && !empty(EMAIL_SMTP_PASSWORD) ? EMAIL_SMTP_PASSWORD : "");
35  }
36  }
37  }
38 
39  private function reset() {
40  $this->ClearAddresses();
41  $this->ClearAllRecipients();
42  $this->ClearAttachments();
43  $this->ClearBCCs();
44  $this->ClearCCs();
45  $this->ClearCustomHeaders();
46  $this->ClearReplyTos();
47  }
48 
49  public function prepare($subject, $body, $to, $from = "", $fromName = "") {
50  $this->reset();
51  if (!empty($to)) {
52  $this->AddAddress($to);
53  }
54  if (!empty($from)) {
55  $this->SetFrom($from, !empty($fromName) ? $fromName : $from);
56  }
57  $this->Subject = $subject;
58  $this->body = $body;
59  $this->AltBody = strip_tags($body);
60  }
61 
62  public function replace($search, $replace) {
63  $this->Subject = str_replace("[*$search*]", $replace, $this->Subject);
64  $this->body = str_replace("[*$search*]", $replace, $this->body);
65  }
66 
67  public function Send() {
68  $this->body = stripslashes($this->body);
69  $this->MsgHTML($this->body);
70  $sent = parent::Send();
71  $this->reset();
72  return $sent;
73  }
74 }
__construct()
Definition: Mail.php:9
replace($search, $replace)
Definition: Mail.php:62
Definition: Account.php:3
Send()
Definition: Mail.php:67
prepare($subject, $body, $to, $from="", $fromName="")
Definition: Mail.php:49