/** * Send the email. * @return boolean */ function send() { if (HookRegistry::call('Mail::send', array($this))) { return; } // Replace all the private parameters for this message. $mailBody = $this->getBody(); if (is_array($this->privateParams)) { foreach ($this->privateParams as $name => $value) { $mailBody = str_replace($name, $value, $mailBody); } } require_once 'lib/pkp/lib/vendor/phpmailer/phpmailer/class.phpmailer.php'; $mailer = new PHPMailer(); $mailer->IsHTML(true); if (Config::getVar('email', 'smtp')) { $mailer->IsSMTP(); $mailer->Port = Config::getVar('email', 'smtp_port'); if (($s = Config::getVar('email', 'smtp_auth')) != '') { $mailer->SMTPSecure = $s; $mailer->SMTPAuth = true; } $mailer->Host = Config::getVar('email', 'smtp_server'); $mailer->Username = Config::getVar('email', 'smtp_username'); $mailer->Password = Config::getVar('email', 'smtp_password'); } $mailer->CharSet = Config::getVar('i18n', 'client_charset'); if (($t = $this->getContentType()) != null) { $mailer->ContentType = $t; } $mailer->XMailer = 'Public Knowledge Project Suite v2'; $mailer->WordWrap = MAIL_WRAP; foreach ((array) $this->getHeaders() as $header) { $mailer->AddCustomHeader($header['key'], $mailer->SecureHeader($header['content'])); } if (($s = $this->getEnvelopeSender()) != null) { $mailer->Sender = $s; } if (($f = $this->getFrom()) != null) { $mailer->SetFrom($f['email'], $f['name']); } if (($r = $this->getReplyTo()) != null) { $mailer->AddReplyTo($r['email'], $r['name']); } foreach ((array) $this->getRecipients() as $recipientInfo) { $mailer->AddAddress($recipientInfo['email'], $recipientInfo['name']); } foreach ((array) $this->getCcs() as $ccInfo) { $mailer->AddCC($ccInfo['email'], $ccInfo['name']); } foreach ((array) $this->getBccs() as $bccInfo) { $mailer->AddBCC($bccInfo['email'], $bccInfo['name']); } $mailer->Subject = $this->getSubject(); $mailer->Body = $mailBody; $mailer->AltBody = PKPString::html2text($mailBody); $remoteAddr = $mailer->SecureHeader(Request::getRemoteAddr()); if ($remoteAddr != '') { $mailer->AddCustomHeader("X-Originating-IP: {$remoteAddr}"); } foreach ((array) $this->getAttachments() as $attachmentInfo) { $mailer->AddAttachment($attachmentInfo['path'], $attachmentInfo['filename'], 'base64', $attachmentInfo['content-type']); } try { $mailer->Send(); } catch (phpmailerException $e) { error_log($mailer->ErrorInfo); return false; } return true; }