mailer = new PHPMailer(true); } public function prepare() { $this->mailer->isSMTP(); $this->mailer->Host = $this->host; $this->mailer->SMTPAuth = true; $this->mailer->Username = $this->fqm; $this->mailer->Password = $this->authpassword; $this->mailer->SMTPSecure = $this->protocol; $this->mailer->Port = ($this->protocol == "tls") ? '587' : '465'; $this->mailer->setFrom($this->from, $this->fromName); $this->mailer->addAddress($this->recipient); $this->mailer->addReplyTo($this->replyto); $this->mailer->isHTML(true); } /** * @param mixed $fqm */ public function setFullyQualifiedAddress($fqm) { $this->fqm = $fqm; return $this; } /** * @param mixed $from */ public function setFrom($from, $fromName) { $this->from = $from; $this->fromName = $fromName; return $this; } /** * @param mixed $host */ public function setHost($host) { $this->host = $host; return $this; } /** * @param mixed $protocol */ public function setProtocol($protocol) { $this->protocol = $protocol; return $this; } /** * @param mixed $recipient */ public function setRecipient($recipient) { $this->recipient = $recipient; return $this; } /** * @param mixed $replyto */ public function setReplyto($replyto) { $this->replyto = $replyto; return $this; } public function setAuthPassword($authpassword) { $this->authpassword = $authpassword; return $this; } public function send($subject, $content) { $this->mailer->Subject = $subject; $this->mailer->Body = $content; try { $this->mailer->send(); return true; } catch (\Exception $ex) { echo "Could not send email! " . $ex->getMessage(); } } }