5 class Mail extends \PHPMailer {
10 parent::__construct();
11 $this->CharSet =
'UTF-8';
13 $this->addCustomHeader(
"X-PHP-Script",
" ");
14 $this->addCustomHeader(
"X-PHP-Filename",
" ");
15 if (defined(
"EMAIL_SMTP") && EMAIL_SMTP === TRUE) {
16 $this->setSmtpConfig();
20 private function setSmtpConfig() {
21 if (defined(
"EMAIL_SMTP_HOSTNAME") && !empty(EMAIL_SMTP_HOSTNAME)) {
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;
28 if (defined(
"EMAIL_SMTP_SECURE") && !empty(EMAIL_SMTP_SECURE)) {
29 $this->SMTPSecure = EMAIL_SMTP_SECURE;
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 :
"");
39 private function reset() {
40 $this->ClearAddresses();
41 $this->ClearAllRecipients();
42 $this->ClearAttachments();
45 $this->ClearCustomHeaders();
46 $this->ClearReplyTos();
49 public function prepare($subject, $body, $to, $from =
"", $fromName =
"") {
52 $this->AddAddress($to);
55 $this->SetFrom($from, !empty($fromName) ? $fromName : $from);
57 $this->Subject = $subject;
59 $this->AltBody = strip_tags($body);
62 public function replace($search, $replace) {
63 $this->Subject = str_replace(
"[*$search*]", $replace, $this->Subject);
64 $this->body = str_replace(
"[*$search*]", $replace, $this->body);
68 $this->body = stripslashes($this->body);
69 $this->MsgHTML($this->body);
70 $sent = parent::Send();
replace($search, $replace)
prepare($subject, $body, $to, $from="", $fromName="")