encodingHelper = acym_get('helper.encoding'); $this->userClass = acym_get('class.user'); $this->config = acym_config(); $this->setFrom($this->config->get('from_email'), $this->config->get('from_name')); $this->Sender = $this->cleanText($this->config->get('bounce_email')); if (empty($this->Sender)) { $this->Sender = ''; } switch ($this->config->get('mailer_method', 'phpmail')) { case 'smtp' : $this->isSMTP(); $this->Host = trim($this->config->get('smtp_host')); $port = $this->config->get('smtp_port'); if (empty($port) && $this->config->get('smtp_secured') == 'ssl') { $port = 465; } if (!empty($port)) { $this->Host .= ':'.$port; } $this->SMTPAuth = (bool)$this->config->get('smtp_auth', true); $this->Username = trim($this->config->get('smtp_username')); $this->Password = trim($this->config->get('smtp_password')); $this->SMTPSecure = trim((string)$this->config->get('smtp_secured')); if (empty($this->Sender)) { $this->Sender = strpos($this->Username, '@') ? $this->Username : $this->config->get('from_email'); } break; case 'sendmail' : $this->isSendmail(); $this->Sendmail = trim($this->config->get('sendmail_path')); if (empty($this->Sendmail)) { $this->Sendmail = '/usr/sbin/sendmail'; } break; case 'qmail' : $this->isQmail(); break; case 'elasticemail' : $port = $this->config->get('elasticemail_port', 'rest'); if (is_numeric($port)) { $this->isSMTP(); if ($port == '25') { $this->Host = 'smtp25.elasticemail.com:25'; } else { $this->Host = 'smtp.elasticemail.com:2525'; } $this->Username = trim($this->config->get('elasticemail_username')); $this->Password = trim($this->config->get('elasticemail_password')); $this->SMTPAuth = true; } else { include_once(ACYM_INC.'phpmailer'.DS.'elasticemail.php'); $this->Mailer = 'elasticemail'; $this->{$this->Mailer} = new acyElasticemail(); $this->{$this->Mailer}->Username = trim($this->config->get('elasticemail_username')); $this->{$this->Mailer}->Password = trim($this->config->get('elasticemail_password')); } break; default : $this->isMail(); break; } if ($this->config->get('dkim', 0) && $this->Mailer != 'elasticemail') { $this->DKIM_domain = $this->config->get('dkim_domain'); $this->DKIM_selector = $this->config->get('dkim_selector', 'acy'); if (empty($this->DKIM_selector)) $this->DKIM_selector = 'acy'; $this->DKIM_passphrase = $this->config->get('dkim_passphrase'); $this->DKIM_identity = $this->config->get('dkim_identity'); $this->DKIM_private = trim($this->config->get('dkim_private')); $this->DKIM_private_string = trim($this->config->get('dkim_private')); } $this->CharSet = strtolower($this->config->get('charset')); if (empty($this->CharSet)) { $this->CharSet = 'utf-8'; } $this->clearAll(); $this->Encoding = $this->config->get('encoding_format'); if (empty($this->Encoding)) { $this->Encoding = '8bit'; } @ini_set('pcre.backtrack_limit', 1000000); $this->SMTPOptions = ["ssl" => ["verify_peer" => false, "verify_peer_name" => false, "allow_self_signed" => true]]; } protected function elasticemailSend($MIMEHeader, $MIMEBody) { $result = $this->elasticemail->sendMail($this); if (!$result) { $this->setError($this->elasticemail->error); } return $result; } public function send() { if (empty($this->Subject) || empty($this->Body)) { $this->reportMessage = acym_translation('ACYM_SEND_EMPTY'); $this->errorNumber = 8; if ($this->report) { acym_enqueueNotification($this->reportMessage, 'error'); } return false; } if (empty($this->ReplyTo) && empty($this->ReplyToQueue)) { if (!empty($this->replyemail)) { $replyToEmail = $this->replyemail; } elseif ($this->config->get('from_as_replyto', 1) == 1) { $replyToEmail = $this->config->get('from_email'); } else { $replyToEmail = $this->config->get('replyto_email'); } if (!empty($this->replyname)) { $replyToName = $this->replyname; } elseif ($this->config->get('from_as_replyto', 1) == 1) { $replyToName = $this->config->get('from_name'); } else { $replyToName = $this->config->get('replyto_name'); } $this->_addReplyTo($replyToEmail, $replyToName); } if ((bool)$this->config->get('embed_images', 0) && $this->Mailer != 'elasticemail') { $this->embedImages(); } if (!$this->alreadyCheckedAddresses) { $this->alreadyCheckedAddresses = true; $replyToTmp = ''; if (!empty($this->ReplyTo)) { $replyToTmp = reset($this->ReplyTo); $replyToTmp = $replyToTmp[0]; } elseif (!empty($this->ReplyToQueue)) { $replyToTmp = reset($this->ReplyToQueue); $replyToTmp = $replyToTmp[1]; } if (empty($replyToTmp) || !acym_isValidEmail($replyToTmp)) { $this->reportMessage = acym_translation('ACYM_VALID_EMAIL').' ( '.acym_translation('ACYM_REPLYTO_EMAIL').' : '.(empty($this->ReplyTo) ? '' : $replyToTmp).' ) '; $this->errorNumber = 9; if ($this->report) { acym_enqueueNotification($this->reportMessage, 'error'); } return false; } if (empty($this->From) || !acym_isValidEmail($this->From)) { $this->reportMessage = acym_translation('ACYM_VALID_EMAIL').' ( '.acym_translation('ACYM_FROM_EMAIL').' : '.$this->From.' ) '; $this->errorNumber = 9; if ($this->report) { acym_enqueueNotification($this->reportMessage, 'error'); } return false; } if (!empty($this->Sender) && !acym_isValidEmail($this->Sender)) { $this->reportMessage = acym_translation('ACYM_VALID_EMAIL').' ( '.acym_translation('ACYM_BOUNCE_EMAIL').' : '.$this->Sender.' ) '; $this->errorNumber = 9; if ($this->report) { acym_enqueueNotification($this->reportMessage, 'error'); } return false; } } if (function_exists('mb_convert_encoding')) { $this->Body = mb_convert_encoding($this->Body, 'HTML-ENTITIES', 'UTF-8'); $this->Body = str_replace(['&', 'ς'], ['&', 'ς'], $this->Body); } if ($this->CharSet != 'utf-8') { $this->Body = $this->encodingHelper->change($this->Body, 'UTF-8', $this->CharSet); $this->Subject = $this->encodingHelper->change($this->Subject, 'UTF-8', $this->CharSet); } if (strpos($this->Host, 'elasticemail')) { $this->addCustomHeader('referral:2f0447bb-173a-459d-ab1a-ab8cbebb9aab'); } $this->Subject = str_replace(['’', '“', '”', '–'], ["'", '"', '"', '-'], $this->Subject); $this->Body = str_replace(" ", ' ', $this->Body); if ($this->ContentType != 'text/plain') { static $foundationCSS = null; $style = ''; if (empty($foundationCSS)) { $foundationCSS = acym_fileGetContent(ACYM_MEDIA.'css'.DS.'libraries'.DS.'foundation_email.min.css'); $foundationCSS = str_replace('#acym__wysid__template ', '', $foundationCSS); } if (strpos($this->Body, 'acym__wysid__template') !== false) $style .= $foundationCSS; static $emailFixes = null; if (empty($emailFixes)) { $emailFixes = acym_fileGetContent(ACYM_MEDIA.'css'.DS.'email.min.css'); } $style .= $emailFixes; if (!empty($this->stylesheet)) $style .= $this->stylesheet; preg_match('@<[^>"t]*body[^>]*>@', $this->Body, $matches); if (empty($matches[0])) $this->Body = '
'.$this->Body.''; $styleFoundInBody = preg_match_all('/<\s*style[^>]*>(.*?)<\s*\/\s*style>/s', $this->Body, $matches); if ($styleFoundInBody) { foreach ($matches[1] as $match) { $style .= $match; } } $emogrifier = new \acymEmogrifier\acymEmogrifier($this->Body, $style); $this->Body = $emogrifier->emogrifyBodyContent(); preg_match('@<[^>"t]*/body[^>]*>@', $this->Body, $matches); if (empty($matches[0])) $this->Body = $this->Body.''; $finalContent = '
'; $finalContent .= ''."\n"; $finalContent .= ''."\n"; $finalContent .= '
'."\n"; $finalContent .= ''; if (!empty($this->headers)) $finalContent .= $this->headers; $finalContent .= ''.$this->Body.'