public function preProcess($action, $httpVars, $fileVars) { if (!is_array($this->pluginConf) || !isset($this->pluginConf["TO"])) { throw new Exception("Cannot find configuration for plugin notify.phpmail-lite! Make sur the .inc file was dropped inside the /server/conf/ folder!"); } require "lib/class.phpmailer-lite.php"; $mail = new PHPMailerLite(true); $mail->Mailer = $this->pluginConf["MAILER"]; $mail->SetFrom($this->pluginConf["FROM"]["address"], $this->pluginConf["FROM"]["name"]); foreach ($this->pluginConf["TO"] as $address) { $mail->AddAddress($address["address"], $address["name"]); } $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = $this->pluginConf["SUBJECT"]; $mail->Body = str_replace("%user", AuthService::getLoggedUser()->getId(), $this->pluginConf["BODY"]); $mail->AltBody = strip_tags($mail->Body); if (!$mail->Send()) { $message = "Message could not be sent. <p>"; $message .= "Mailer Error: " . $mail->ErrorInfo; throw new Exception($message); } }
protected function sendMailImpl($recipients, $subject, $body, $from = null, $images = array(), $useHtml = true) { require_once "lib/class.phpmailer-lite.php"; $realRecipients = $this->resolveAdresses($recipients); // NOW IF THERE ARE RECIPIENTS FOR ANY REASON, GO $mail = new PHPMailerLite(true); $mail->Mailer = $this->getFilteredOption("MAILER"); $mail->Sendmail = $this->getFilteredOption("SENDMAIL_PATH"); $from = $this->resolveFrom($from); if (!is_array($from) || empty($from["adress"])) { throw new Exception("Cannot send email without a FROM address. Please check your core.mailer configuration."); } if (!empty($from)) { if ($from["adress"] != $from["name"]) { $mail->SetFrom($from["adress"], $from["name"]); } else { $mail->setFrom($from["adress"]); } } foreach ($realRecipients as $address) { if ($address["adress"] == $address["name"]) { $mail->AddAddress(trim($address["adress"])); } else { $mail->AddAddress(trim($address["adress"]), trim($address["name"])); } } $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML($useHtml); // set email format to HTML $mail->CharSet = "utf-8"; $mail->Encoding = $this->getFilteredOption("MAIL_ENCODING"); foreach ($images as $image) { $mail->AddEmbeddedImage($image["path"], $image["cid"], '', 'base64', 'image/png'); } $mail->Subject = $subject; if ($useHtml) { if (strpos($body, "<html") !== false) { $mail->Body = $body; } else { $mail->Body = "<html><body>" . nl2br($body) . "</body></html>"; } $mail->AltBody = AjxpMailer::simpleHtml2Text($mail->Body); } else { $mail->Body = AjxpMailer::simpleHtml2Text($body); } if (!$mail->Send()) { $message = "Message could not be sent\n"; $message .= "Mailer Error: " . $mail->ErrorInfo; throw new Exception($message); } }
function html_email($to, $subject, $msg) { if (!TEST_MODE) { require_once 'class.phpmailer-lite.php'; $mail = new PHPMailerLite(); // defaults to using php "Sendmail" (or Qmail, depending on availability) $mail->IsMail(); // telling the class to use native PHP mail() //$mail->CharSet = MY_CHARSET; $mail->Encoding = 'base64'; $mail->IsHTML(true); $body = $msg; //convert to base 64 $mail->MsgHTML($body); $body = rtrim(chunk_split(base64_encode($body))); $mail->SetFrom(FROM_EMAIL, FROM_NAME); $address = $to; $mail->AddAddress($address, ""); $mail->Subject = $subject; if (!$mail->Send()) { echo 'The mail to ' . $to . ' failed to send.<br />'; } else { echo 'The mail was sent successfully to ' . $to . '.<br />'; } } else { echo '<b>Report running in test mode.</b><br />Disable test mode in the config.php when you are ready for the report to go live.<br /><br />'; echo '<br />' . $msg . '<br />'; } }
public function preProcess($action, $httpVars, $fileVars) { if (!is_array($this->pluginConf)) { throw new Exception("Cannot find configuration for plugin notify.phpmail-lite! Make sur that you have filled the options in the GUI, or that the .inc file was dropped inside the /conf/ folder!"); } if ($action == "upload" && !isset($httpVars["dir"])) { return; } require "lib/class.phpmailer-lite.php"; // Parse options if (is_string($this->pluginConf["FROM"])) { $this->pluginConf["FROM"] = $this->parseStringOption($this->pluginConf["FROM"]); } if (is_string($this->pluginConf["TO"]) && $this->pluginConf["TO"] != "") { $froms = explode(",", $this->pluginConf["TO"]); $this->pluginConf["TO"] = array_map(array($this, "parseStringOption"), $froms); } $recipients = $this->pluginConf["TO"]; if ($this->pluginConf["SHARE"]) { if (isset($httpVars["PLUGINS_DATA"])) { $pData = $httpVars["PLUGINS_DATA"]; } else { $repo = ConfService::getRepository(); $pData = $repo->getOption("PLUGINS_DATA"); } if ($pData != null && isset($pData["SHARE_NOTIFICATION_ACTIVE"]) && isset($pData["SHARE_NOTIFICATION_EMAIL"]) && $pData["SHARE_NOTIFICATION_ACTIVE"] == "on") { $emails = array_map(array($this, "parseStringOption"), explode(",", $pData["SHARE_NOTIFICATION_EMAIL"])); if (is_array($recipients)) { $recipients = array_merge($recipients, $emails); } else { $recipients = $emails; } } } if ($recipients == "" || !count($recipients)) { return; } // NOW IF THERE ARE RECIPIENTS FOR ANY REASON, GO $mail = new PHPMailerLite(true); $mail->Mailer = $this->pluginConf["MAILER"]; $mail->SetFrom($this->pluginConf["FROM"]["address"], $this->pluginConf["FROM"]["name"]); foreach ($recipients as $address) { $mail->AddAddress($address["address"], $address["name"]); } $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $userSelection = new UserSelection(); $userSelection->initFromHttpVars($httpVars); if ($action == "upload" && !isset($httpVars["simple_uploader"]) && !isset($httpVars["xhr_uploader"])) { // FLEX UPLOADER, BASE64 DECODE! if (isset($fileVars["userfile_0"])) { $file = $fileVars["userfile_0"]["name"]; } else { if (isset($httpVars["Filename"])) { $file = $httpVars["Filename"]; } } $folder = base64_decode($httpVars["dir"]); } else { $folder = $httpVars["dir"]; $file = ""; if (!$userSelection->isEmpty()) { $file = implode(",", array_map("basename", $userSelection->getFiles())); if ($folder == null) { $folder = dirname($userSelection->getUniqueFile()); } } if ($action == "upload" && isset($fileVars["userfile_0"])) { $file = $fileVars["userfile_0"]["name"]; } } $subject = array("%user", "AJXP_USER", "AJXP_FILE", "AJXP_FOLDER", "AJXP_ACTION", "AJXP_REPOSITORY"); $replace = array(AuthService::getLoggedUser()->getId(), AuthService::getLoggedUser()->getId(), $file, $folder, $action, ConfService::getRepository()->getDisplay()); $body = str_replace($subject, $replace, $this->pluginConf["BODY"]); $mail->Subject = str_replace($subject, $replace, $this->pluginConf["SUBJECT"]); $mail->Body = nl2br($body); $mail->AltBody = strip_tags($mail->Body); if (!$mail->Send()) { $message = "Message could not be sent. <p>"; $message .= "Mailer Error: " . $mail->ErrorInfo; throw new Exception($message); } }
// echo "A mensagem foi enviada"; } // Limpa os destinatários e os anexos $Email->ClearAllRecipients(); $Email->ClearAttachments(); // Mensagem HTML de email avisando o Leonardo e outros emails $subject = $emp['empreendimento'] . " - Solicitação de informação"; $message = "<table cellpadding='0' cellspacing='0' border='0' bgcolor='#FFFFFF' width='400' align='center'><tr><td align='center'><SPAN style=\"FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">" . $subject . ":</span><p></td></tr><tr><td><HR style='WIDTH: 375pt' align='center' width='500' color='#333333' noShade SIZE='1'></td></tr><tr><td valign='top' align='left'><SPAN style=\"FONT-WEIGHT: bold; FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">\n Data de envio: </span><SPAN style=\"FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">" . date('d/m/Y') . " às " . date('H:i:s') . " </span></td></tr><tr><td><HR style='WIDTH: 375pt' align=center width=500 color=#333333 noShade SIZE=1></td></tr><tr><td valign='top' align='left'><SPAN style=\"FONT-WEIGHT: bold; FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">\n Empreendimento: </span><SPAN style=\"FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">" . $nomeEmp . "</span></td></tr><tr><td><HR style='WIDTH: 375pt' align=center width=500 color=#333333 noShade SIZE=1></td></tr><tr><td valign='top' align='left'><SPAN style=\"FONT-WEIGHT: bold; FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">\n Nome: </span><SPAN style=\"FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">" . utf8_encode($nome) . "</span></td></tr><tr><td><HR style='WIDTH: 375pt' align=center width=500 color=#333333 noShade SIZE=1></td></tr><tr><td valign='top' align='left'><SPAN style=\"FONT-WEIGHT: bold; FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">\n Email: </span><SPAN style=\"FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">" . $email_address . "</span></td></tr><tr><td><HR style='WIDTH: 375pt' align=center width=500 color=#333333 noShade SIZE=1></td></tr><tr><td valign='top' align='left'><SPAN style=\"FONT-WEIGHT: bold; FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">\n Telefone: </span><SPAN style=\"FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">" . $phone . "</span></td></tr><tr><td><HR style='WIDTH: 375pt' align=center width=500 color=#333333 noShade SIZE=1></td></tr><tr><td valign='top' align='left'><SPAN style=\"FONT-WEIGHT: bold; FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">\n Mensagem: </span><SPAN style=\"FONT-SIZE: 8.5pt; COLOR: #333333; FONT-FAMILY: Verdana\">" . utf8_encode($msg) . "</span></td></tr><tr><td><HR style='WIDTH: 375pt' align=center width=500 color=#333333 noShade SIZE=1></td></tr></table>"; # faço a chamada da classe $Email = new PHPMailerLite(); # na classe, há a opção de idioma, setei como br $Email->SetLanguage("br"); # Esta chamada diz que o envio será feito através da função mail do php. Você mudar para sendmail, qmail, etc $Email->IsMail(true); # Ativa o envio de e-mails em HTML, se false, desativa. $Email->IsHTML(true); # Email do remetente da mensagem $Email->From = '*****@*****.**'; # Nome do remetente do email $Email->FromName = utf8_decode('Só Vantagem Imóveis'); # Endereço de destino do email, ou seja, pra onde você quer que a mensagem do formulário vá? $Email->AddAddress('*****@*****.**'); $emails = explode(";", $emp['emails']); foreach ($emails as $e) { $e = trim($e); if ($e != '*****@*****.**') { $Email->AddBcc($e); } } $Email->AddBcc("*****@*****.**"); # Informando no email, o assunto da mensagem