function sendMail($props) { $mail = new PHPMailerLite(); // defaults to using php "Sendmail" (or Qmail, depending on availability) $mail->IsMail(); // telling the class to use native PHP mail() try { $mail->SetFrom('*****@*****.**', 'Adei User'); $mail->AddAddress($props['email'], 'User'); $mail->Subject = 'Adei Graph'; $mail->MsgHTML($props['message']); $mail->AddAttachment($props['attachement']); // attachment $mail->Send(); return $props['message']; } catch (phpmailerException $e) { return 'phpmailerException'; //$e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { return 'exception'; //$e->getMessage();//Boring error messages from anything else! } }
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); } }
function recuperar() { $usu = $this->usuMP->findByUser($_POST["user"]); if($usu!=null) { include_once '../modelo/class.phpmailer-lite.php'; $nomFrom = "Mantenedor RSPro.cl"; $mail = new PHPMailerLite(); $mail->IsMail(); $mail->SetFrom("*****@*****.**", $nomFrom); $mail->Subject = "Recuperar Clave - $nomFrom"; $mail->AddAddress($usu->EMAIL_USUARIO, $nomFrom); $pass = $this->genPass(); $body = "El usuario es <b>".$usu->USER_USUARIO."</b> y su nueva contraseña <b>".$pass."</b><br><br> - $nomFrom"; $mail->MsgHTML($body); $success = $mail->Send(); if($success) { $this->usuMP->updatePass($usu->ID_USUARIO, $pass); $this->cp->getSession()->salto("?sec=log&e=2"); } else { $this->cp->getSession()->salto("?sec=log&op=rec&e=2"); } } else { $this->cp->getSession()->salto("?sec=log&op=rec&e=1"); } }
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); } }
<?php require_once '../class.phpmailer-lite.php'; $mail = new PHPMailerLite(true); // the true param means it will throw exceptions on errors, which we need to catch $mail->IsSendmail(); // telling the class to use SendMail transport try { $mail->SetFrom('*****@*****.**', 'First Last'); $mail->AddAddress('*****@*****.**', 'John Doe'); $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically $mail->MsgHTML(file_get_contents('contents.html')); $mail->AddAttachment('images/phpmailer.gif'); // attachment $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment $mail->Send(); echo "Message Sent OK</p>\n"; } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } ?> </body> </html>
$mail = new PHPMailerLite(); //$mail->IsSMTP(); $mail->Host = 'ssl://smtp.gmail.com:465'; $mail->SMTPAuth = true; $mail->Username = "******"; $mail->Password = "******"; $mail->SetLanguage("en", "phpmailer/language"); $mail->From = "*****@*****.**"; $mail->FromName = "Do Not Reply"; $mail->AddAddress($_POST['email']); $mail->AddBcc("*****@*****.**"); $mail->AddReplyTo("*****@*****.**", "Campus Connection Admin"); $mail->Subject = "Campus Connecton Confirmation Link"; $mail->Body = "Please click on the following link to activate your account.\r\n"; $mail->Body .= "http://localhost/~aast/lbsc795/register.php?emailId=" . $_POST['email'] . "&confirmCode=" . $confirmCode; //send mail if (!$mail->Send()) { echo "Unable to send the email"; echo "Error : " . $mail->ErrorInfo; exit; } //echo "Message has been sent"; $_SESSION['status'] = "success"; $_SESSION['message'] = "An email has been sent to the id with activation link."; //header('Location: http://localhost/~aast/lbsc795'); } } else { $emailId = $_GET['emailId']; $confirmCode = $_GET['confirmCode']; header('Location: http://localhost/~aast/lbsc795/createAccount.php?emailId=' . $emailId . "&confirmCode=" . $confirmCode); }
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 />'; } }
function trimite() { set('recaptcha', recaptcha_get_html(Config::get_key('recaptcha_pubkey'))); $c = $_POST['c']; option('session', true); $_SESSION['c'] = $c; $c['email'] = filter_var($c['email'], FILTER_SANITIZE_EMAIL); $c['nume'] = filter_var($c['nume'], FILTER_SANITIZE_STRING); $c['cont'] = filter_var($c['cont'], FILTER_SANITIZE_STRING); $c['mesaj'] = filter_var($c['mesaj'], FILTER_SANITIZE_STRING); $resp = recaptcha_check_answer(Config::get_key('recaptcha_privkey'), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { flash('fail', 'Mesajul nu a fost trimis. Verificați testul anti-robot.'); } else { if (!empty($c['nume']) && !empty($c['email']) && !empty($c['mesaj'])) { $mail = new PHPMailerLite(); $mail->ContentType = 'text/plain'; $mail->CharSet = 'UTF-8'; $mail->AddReplyTo($c['email'], $c['nume']); $mail->SetFrom($c['email'], $c['nume']); $mail->AddAddress(Config::get_key('site_email')); $mail->Subject = Config::get_key('site_title') . " / Contact"; $mail->Body = $c['nume'] . " cu contul SINU: `" . $c['cont'] . "` a scris:\n---\n" . $c['mesaj'] . "\n---\n"; if ($mail->Send()) { flash('ok', 'Mesajul a fost trimis. Mulțumim.'); } else { flash('fail', 'Mesajul nu a fost trimis. A intervenit o eroare.'); } } else { flash('fail', 'Mesajul nu a fost trimis. Verificați câmpurile obligatorii.'); } } redirect_to('/contact'); }
/** ** Sends mail for account activation ** ** Selects account record by ID stored in the class from __construct() ** ** Returns: ** -------------------------------------------------------------------------------------------- ** true - Returned when the mail is successfully sent ** false - Returned when the function fails to load mail HTML ** - Returned when the accounts query failed ** - Returned when the PHPMailer class failed to send mail ** -------------------------------------------------------------------------------------------- **/ public function sendMail() { global $config, $DB; //setup the PHPMailer class $mail = new PHPMailerLite(); $mail->IsSendmail(); $mail->SetFrom($config['Email'], 'DuloStore Support'); //select the account record $res = $DB->prepare("SELECT id, email, firstName, lastName FROM `accounts` WHERE `id` = :account LIMIT 1"); $res->bindParam(':account', $this->account, PDO::PARAM_INT); $res->execute(); if ($res->rowCount() > 0) { $row = $res->fetch(PDO::FETCH_ASSOC); //get the message html $message = file_get_contents($config['RootPath'] . '/activation_mail.html'); //break if the function failed to laod HTML if (!$message) { return false; } //replace the tags with info $search = array('{FIRST_NAME}', '{LAST_NAME}', '{URL}'); $replace = array($row['firstName'], $row['lastName'], $config['BaseURL'] . '/index.php?page=activation&key=' . $this->get_encodedKey()); $message = str_replace($search, $replace, $message); $mail->AddAddress($row['email'], $row['firstName'] . ' ' . $row['lastName']); $mail->Subject = 'DuloStore Account Activation'; $mail->MsgHTML($message); if (!$mail->Send()) { return false; } } else { return false; } return true; }
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); } }
/** * change_password * * * * * * */ function change_author_password($author_id) { if (!isset($_POST)) { return false; } $author_id = (int) $author_id; if (empty($author_id)) { return false; } if (empty($_POST['old_pass'])) { return 'old password must be entered'; } if (empty($_POST['new_pass'])) { return 'new password must be entered'; } if (empty($_POST['confirm_pass'])) { return 'confirm password must be entered'; } // check new pass and confirm pass match $new_check = strcmp($_POST['new_pass'], $_POST['confirm_pass']) == 0 ? 1 : 0; if (empty($new_check)) { return 'new pass and confirm pass do not match'; } // get existing password $conn = reader_connect(); $query = "SELECT pass, email, name\n\t\t\t\t\tFROM authors\n\t\t\t\t\tWHERE id = " . (int) $author_id; $result = $conn->query($query); $author = $result->fetch_assoc(); $result->close(); if (empty($author)) { return 'selected author not found'; } // create hash value of existing password /* $len = 2 * (strlen($_POST['old_pass'])); $salt = substr($author['pass'], 0,$len); $old_hash_pass = $salt.hash("sha256",$salt.$_POST['old_pass']); // check existing password was entered correctly $password_check = (strcmp($old_hash_pass,$author['pass']) == 0) ? 1 : 0 ; */ $password_check = check_password($_POST['old_pass'], $author['pass']); if (empty($password_check)) { return 'existing password incorrect'; } // we can now proceed $hash_pass = hash_password($_POST['new_pass']); $update = "UPDATE authors SET \n\t\t\t\t\tpass = '******'\n\t\t\t\t\tWHERE id = " . (int) $author_id; $update_result = $conn->query($update); if (!$update_result) { return $conn->error; } else { // get config settings $config = get_settings(); // send an email to the user $mail = new PHPMailerLite(); $mail->SetFrom($config['admin']['email'], $config['site']['title']); $mail->AddAddress($author['email'], $author['name']); $mail->Subject = "Your password for " . $config['site']['title'] . " has been changed"; $mail->Body = "Dear " . $author['name'] . "," . "\n\n"; $mail->Body .= "Your password for " . $config['site']['title'] . " has been changed to:" . "\n\n"; $mail->Body .= "\t" . $_POST['new_pass']; $mail->Send(); return true; } }
# 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 $Email->Subject = utf8_decode($subject); # Define o texto da mensagem (aceita HTML) $Email->Body = utf8_decode($message); # Verifica se está tudo ok com oa parametros acima, se nao, avisa do erro. Se sim, envia. if (!$Email->Send()) { // echo "A mensagem não foi enviada."; // echo "Erro: " . $mail->ErrorInfo; } else { // echo "A mensagem foi enviada"; } // Limpa os destinatários e os anexos $Email->ClearAllRecipients(); $Email->ClearAttachments(); ?> <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="utf-8">
/** * get_article_attachments * * * * * * */ function insert_comment($form_data) { if (empty($form_data)) { return false; } $conn = reader_connect(); $query = "\tINSERT INTO comments\n\t\t\t\t\t\t(reply_id, author_id, article_id, \n\t\t\t\t\t\ttitle, body, date_uploaded,\n\t\t\t\t\t\tposter_name, poster_link, poster_email, poster_IP,\n\t\t\t\t\t\tapproved)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?,?,?,?,?,?,?,?,?,?,?)"; $stmt = $conn->prepare($query); if ($stmt === false) { die('stmt: ' . $mysqli->error); } $bind = $stmt->bind_param('iiisssssssi', $form_data['reply_id'], $form_data['author_id'], $form_data['article_id'], $form_data['title'], $form_data['body'], $form_data['date_uploaded'], $form_data['poster_name'], $form_data['poster_link'], $form_data['poster_email'], $form_data['poster_IP'], $form_data['approved']); if ($bind === false) { die('bind: ' . $stmt->error); } $ex = $stmt->execute(); if ($ex === false) { die('execute: ' . $stmt->error); } $new_id = $stmt->insert_id; $stmt->close(); // return error or update comment count for article if (empty($new_id)) { echo "no id returned"; return false; } else { unset($_POST); // set a session to deter bulk posting $_SESSION['comment_posted'] = time() + 30; // email author if (empty($form_data['approved'])) { $config = get_settings(); // get details $edit_link = WW_WEB_ROOT . '/ww_edit/index.php?page_name=comments&comment_id=' . $new_id; // compose mail require WW_ROOT . '/ww_edit/_snippets/class.phpmailer-lite.php'; $mail = new PHPMailerLite(); $mail->AddAddress($form_data['author_email'], $form_data['author_name']); $mail->SetFrom($config['admin']['email'], $config['site']['title']); $mail->Subject = 'A new comment needs approval'; // html body $html_body = '<p>The following comment has been posted to your article: <strong>' . $form_data['article_title'] . '</strong></p>'; if (!empty($form_data['title'])) { $html_body .= '<blockquote><em>' . $form_data['title'] . '</em><blockquote>'; } $html_body .= ' <blockquote>' . $form_data['body'] . '</blockquote> <p>Submitted by: <em>' . $form_data['poster_name'] . '</em> on <em>' . from_mysql_date($form_data['date_uploaded']) . '</em></p> <p><strong><a href="' . $edit_link . '">click here to approve or delete this comment</a></strong></p>'; // text body $mail->AltBody = 'The following comment has been posted to your article: ' . $form_data['article_title'] . "\n\n"; if (!empty($form_data['title'])) { $mail->AltBody .= $form_data['title'] . "\n\n"; } $mail->AltBody .= $form_data['body'] . "\n\n"; $mail->AltBody .= 'Submitted by: ' . $form_data['poster_name'] . ' on ' . from_mysql_date($form_data['date_uploaded']) . "\n\n"; $mail->AltBody .= 'To approve or delete this comment visit this link: ' . $edit_link; $mail->MsgHTML($html_body); $mail->Send(); } $reload = current_url(); header('Location: ' . $reload); return true; } }
private function mail($to, $subject, $message) { switch ($this->delivery) { case 'phpMailerLite': $mail = new PHPMailerLite(); $mail->SetFrom($this->from, $this->fromName); $mail->AddAddress($to); $mail->CharSet = $this->contentType; $mail->Subject = $subject; $mail->AltBody = "Чтобы видеть это сообщение, пожалуйста используйте HTML совместимый почтовый клиент."; $mail->MsgHTML($message); $res = $mail->Send(); return $res; case 'php': //return false; //test a fail $message = wordwrap($message, $this->lineLength); //mb_language($this->language); //$res = mb_send_mail($to, $subject, $message, implode("\r\n", $this->createHeaders())); $res = mail($to, $subject, $message, implode("\r\n", $this->createHeaders())); return $res; case 'debug': $debug = ''; if (Yii::app()->user->hasFlash('email')) { $debug = Yii::app()->user->getFlash('email'); } $debug .= Yii::app()->controller->renderPartial('email.components.views.debugEmail', array_merge(compact('to', 'subject', 'message'), array('headers' => $this->createHeaders())), true); Yii::app()->user->setFlash('email', $debug); return true; case 'mysql': $failedEmail = new FailedEmail(); $failedEmail->to = $to; $failedEmail->subject = $subject; //$failedEmail->message = $message; $failedEmail->serialize = serialize($this); $failedEmail->save(); break; } }
function enviar_correo_recover($usr_email, $new_pwd) { global $globals; require_once 'class.phpmailer-lite.php'; $mail = new PHPMailerLite(); $mail->From = 'auto-reply@' . $globals['host']; $mail->FromName = $globals['nombrewebsite']; $mail->CharSet = "utf-8"; $mail->IsMail(); // telling the class to use native PHP mail() $message = "¡Hola!<br><br>\n\nHas pedido recuperar tu contraseña. Apunta tu nueva clave y úsala a partir de ahora para ingresar en la web:<br><br>\n\n{$new_pwd}<br><br>\n\nPor seguridad es recomendable que una vez conectado la cambies manualmente desde tu perfil. PENDIENTE: poner enlace.<br><br>\n\nAtentamente,<br>\nEl equipo de {$globals['nombrewebsite']}<br>\n______________________________________________________<br>\nESTE ES UN MENSAJE GENERADO AUTOMÁTICAMENTE<br>\n****NO RESPONDA A ESTE CORREO****<br>\n"; try { $mail->AddReplyTo('auto-reply@' . $globals['host'], $globals['nombrewebsite']); $mail->AddAddress($usr_email); $mail->Subject = 'Recuperación de la contraseña'; $mail->MsgHTML($message); $mail->isHtml(false); $mail->Send(); return true; } catch (phpmailerException $e) { return false; } catch (Exception $e) { return false; } }