Exemplo n.º 1
2
 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!
     }
 }
Exemplo n.º 2
0
 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");
     }
 }
</head>
<body>

<?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!
}
?>
Exemplo n.º 4
0
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 />';
    }
}
Exemplo n.º 5
0
<title>PHPMailer - Sendmail basic test</title>
</head>
<body>

<?php 
require_once '../class.phpmailer-lite.php';
$mail = new PHPMailerLite();
// defaults to using php "Sendmail" (or Qmail, depending on availability)
$body = file_get_contents('contents.html');
$body = eregi_replace("[\\]", '', $body);
$mail->SetFrom('*****@*****.**', 'First Last');
$address = "*****@*****.**";
$mail->AddAddress($address, "John Doe");
$mail->Subject = "PHPMailer Test Subject via Sendmail, basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
// optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.gif");
// attachment
$mail->AddAttachment("images/phpmailer_mini.gif");
// attachment
if (!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}
?>

</body>
</html>
Exemplo n.º 6
0
 /**
  **  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;
 }
/**
 * 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;
    }
}
Exemplo n.º 8
0
 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;
     }
 }
Exemplo n.º 9
0
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;
    }
}
Exemplo n.º 10
0
<?php
include_once 'modelo/class.phpmailer-lite.php';

$email = "*****@*****.**";
$mail = new PHPMailerLite();
$mail->IsMail();
$mail->SetFrom($email, "GPSLine");
$mail->Subject = "GPSLine - Alerta activada";
$mail->AddAddress("*****@*****.**", "*****@*****.**");
$mail->AddAddress("*****@*****.**", "*****@*****.**");
$mail->AddAddress("*****@*****.**", "*****@*****.**");
$html = "lala";
$mail->MsgHTML($html);
echo $html."<br>";
$mail->Send();

?>