private static function sendAutoResponseEmail($mailer) { $senderEmail = Form::getSenderEmail(); $body = Form::getAutoResponseMailBody(); if (empty($senderEmail) || empty($body)) { return false; } $mailer->From = Form::getFromEmail(true); $mailer->FromName = Form::getFromName(true); $mailer->TO = $senderEmail; $mailer->CC = ''; //Form::getToEmail(); $mailer->BCC = ''; $replyTo = Form::getReplyToEmail(); if (!empty($replyTo)) { $mailer->ReplyTo = $replyTo; $mailer->ReplyToName = Form::getReplyToName(); } $mailer->Subject = Form::getAutoResponseMailSubject(); $mailer->Body = $body; return $mailer->Send(); }
private function SendByPHPMailer() { $email = $this->config['email']; $mailer = new \PHPMailer(); $mailer->From = $this->From; $mailer->FromName = $this->FromName; $mailer->Subject = $this->Subject; $mailer->Body = $this->Body; $mailer->CharSet = 'UTF-8'; $mailer->msgHTML($mailer->Body); $mailer->IsHtml(true); $mailer->AddAddress($this->TO); if (empty($this->ReplyTo)) { $senderEmail = Form::getSenderEmail(); $this->ReplyTo = empty($senderEmail) ? $this->From : $senderEmail; $this->ReplyToName = $this->FromName; } $mailer->AddReplyTo($this->ReplyTo, $this->ReplyToName); if (!empty($this->CC)) { $CCs = explode(',', $this->CC); foreach ($CCs as $c) { $mailer->AddCC($c); } } if (!empty($this->BCC)) { $BCCs = explode(',', $this->BCC); foreach ($BCCs as $b) { $mailer->AddBCC($b); } } $attachments = Form::getAttachments(); //$this->addLog($attachments); if (is_array($attachments)) { foreach ($attachments as $f) { $mailer->AddAttachment($f['path'], basename($f['name'])); } } $smtp = $this->config['smtp']; $isSMTP = $this->mailer == 'smtp' && !empty($smtp); if ($isSMTP) { $mailer->IsSMTP(); $mailer->Host = $smtp['host']; $mailer->Username = $smtp['user']; $mailer->Password = $smtp['password']; $mailer->SMTPAuth = !empty($mailer->Password); $mailer->SMTPSecure = $smtp['security']; $mailer->Port = empty($smtp['port']) ? 25 : $smtp['port']; $mailer->SMTPDebug = empty($smtp['debug']) ? 0 : 2; } if ($isSMTP && $mailer->SMTPDebug > 0) { ob_start(); } $this->isSent = $mailer->Send(); if ($isSMTP && $mailer->SMTPDebug > 0) { $debug = ob_get_contents(); ob_end_clean(); $this->addLog($debug); } if (!$sent) { $this->sendError = $mailer->ErrorInfo; } $this->sentMIMEMessage = $mailer->getSentMIMEMessage(); return $this->isSent; }