Example #1
2
function sendmail($subject, $mailcontent, $receiver, $receivername, $attachment = "")
{
    if (strpos($_SERVER['HTTP_HOST'], "localhost")) {
        return false;
    }
    $mail = new phpmailer();
    $mail->IsSMTP();
    $mail->Host = "mail.pepool.com";
    $mail->Port = 2525;
    $mail->SMTPAuth = true;
    $mail->Username = "******";
    // Write SMTP username in ""
    $mail->Password = "******";
    $mail->Mailer = "smtp";
    $mail->IsHTML(true);
    $mail->ClearAddresses();
    $mail->From = "*****@*****.**";
    $mail->FromName = "pepool";
    $mail->Subject = $subject;
    $mail->Body = $mailcontent;
    $mail->AddAddress($receiver, $receivername);
    if ($attachment != '') {
        $mail->AddAttachment($attachment);
    }
    $suc = $mail->Send();
    return $suc > 0;
}
Example #2
1
 /**
  * Send mail, similar to PHP's mail
  *
  * A true return value does not automatically mean that the user received the
  * email successfully. It just only means that the method used was able to
  * process the request without any errors.
  *
  * The default content type is 'text/plain' which does not allow using HTML.
  */
 public static function send($from_email, $from_name, array $to, $subject, $message, array $cc = array(), array $bcc = array(), array $attachments = array())
 {
     $mailer = new phpmailer();
     $content_type = 'text/plain';
     $mailer->ContentType = $content_type;
     $mailer->Hostname = \lib\conf\constants::$domain;
     $mailer->IsMail();
     $mailer->IsHTML(false);
     $mailer->From = $from_email;
     $mailer->FromName = $from_name;
     // add recipients
     foreach ((array) $to as $recipient_name => $recipient_email) {
         $mailer->AddAddress(trim($recipient_email), trim($recipient_name));
     }
     // Add any CC and BCC recipients
     foreach ($cc as $recipient_name => $recipient_email) {
         $mailer->AddCc(trim($recipient_email), trim($recipient_name));
     }
     foreach ($bcc as $recipient_name => $recipient_email) {
         $mailer->AddBcc(trim($recipient_email), trim($recipient_name));
     }
     // Set mail's subject and body
     $mailer->Subject = $subject;
     $mailer->Body = $message;
     foreach ($attachments as $attachment) {
         $mailer->AddAttachment($attachment);
     }
     // Send!
     $result = $mailer->Send();
     return $result;
 }
Example #3
1
 /**
  * Activate a given user.
  * @param	$id				Identifier of user.
  * @param	$activationKey	Activation key for user.
  */
 function activateUser($id, $activationKey)
 {
     if (!empty($id) && !empty($activationKey)) {
         global $dbi;
         global $lActivate;
         $result = $dbi->query("SELECT username,activationKey FROM " . userTableName . " WHERE id=" . $dbi->quote($id));
         if ($result->rows()) {
             list($username, $activationKeyDB) = $result->fetchrow_array();
             if ($activationKey == $activationKeyDB) {
                 $dbi->query("UPDATE " . userTableName . " SET registered=registered,lastUpdated=lastUpdated,lastLogged=lastLogged,activated=1,activationKey='' WHERE id=" . $dbi->quote($id));
                 // Send confirmation email
                 $result = $dbi->query("SELECT name,email FROM " . userDataTableName . " WHERE id=" . $dbi->quote($id));
                 if ($result->rows()) {
                     list($name, $email) = $result->fetchrow_array();
                     // Send activation email
                     $mail = new phpmailer();
                     $mail->CharSet = "UTF-8";
                     $mail->Sender = pageAdminMail;
                     $mail->From = pageAdminMail;
                     $mail->FromName = pageTitle;
                     $mail->Subject = $lActivate["MailSubject"];
                     $mail->Body = sprintf($lActivate["MailMessage"], $name, $username);
                     $mail->IsHTML(false);
                     $mail->AddAddress($email);
                     $mail->Send();
                 }
                 echo '<p>' . $lActivate["HeaderText"] . '</p>';
             } else {
                 echo '<p>' . $lActivate["HeaderTextError"] . '</p>';
             }
         }
     }
 }
Example #4
1
 function f_SEND($t_email = '', $t_asunto = '', $t_contenido)
 {
     require_once '../modelo/phpmailer/class.phpmailer.php';
     $a_email = new phpmailer();
     $a_email->Mailer = "smtp";
     $a_email->Host = "";
     $a_email->SMTPAuth = true;
     $a_email->Port = '465';
     $a_email->CharSet = 'utf8';
     $a_email->Username = '';
     $a_email->Password = '';
     $a_email->From = '';
     $a_email->FromName = '' . utf8_decode('');
     //escribir la el contenido del correo
     //dirección destino
     $a_correo = '' . $t_email;
     $a_email->addAddress($a_correo);
     $a_email->Subject = '' . utf8_decode('' . $t_asunto);
     $a_email->AddEmbeddedImage('../imagenes/inen_header.png', 'logoinen', 'inen_header.png');
     $a_email->IsHTML(true);
     $a_email->Body = "<p><img src=\"cid:logoinen\" /></p><p>" . utf8_decode('' . $t_contenido) . "</p>";
     $a_email->AltBody = ' ';
     if ($a_email->send()) {
         echo "</br>Mensaje enviado correctamente.</br>";
     } else {
         echo "<br/><strong>Información:</strong><br/>" . $a_email->ErrorInfo;
     }
 }
Example #5
1
/**
 * Send an email to a specified user
 *
 * @uses $CFG
 * @param user $user  A {@link $USER} object
 * @param user $from A {@link $USER} object
 * @param string $subject plain text subject line of the email
 * @param string $messagetext plain text version of the message
 * @param string $messagehtml complete html version of the message (optional)
 * @param string $attachment a file on the filesystem
 * @param string $attachname the name of the file (extension indicates MIME)
 * @param bool $usetrueaddress determines whether $from email address should
 *          be sent out. Will be overruled by user profile setting for maildisplay
 * @return bool|string Returns "true" if mail was sent OK, "emailstop" if email
 *          was blocked by user and "false" if there was another sort of error.
 */
function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '', $attachment = '', $attachname = '', $usetrueaddress = true, $replyto = '', $replytoname = '')
{
    global $CFG;
    $textlib = textlib_get_instance();
    include_once $CFG->libdir . '/phpmailer/class.phpmailer.php';
    if (empty($user) || empty($user->email)) {
        return false;
    }
    /*
    if (over_bounce_threshold($user)) {
        error_log("User $user->id (".fullname($user).") is over bounce threshold! Not sending.");
        return false;
    }
    */
    // this doesn't exist right now, we may bring it in later though.
    $mail = new phpmailer();
    $mail->Version = 'Elgg ';
    // mailer version (should have $CFG->version on here but we don't have it yet)
    $mail->PluginDir = $CFG->libdir . '/phpmailer/';
    // plugin directory (eg smtp plugin)
    $mail->CharSet = 'UTF-8';
    // everything is now uft8
    if (empty($CFG->smtphosts)) {
        $mail->IsMail();
        // use PHP mail() = sendmail
    } else {
        if ($CFG->smtphosts == 'qmail') {
            $mail->IsQmail();
            // use Qmail system
        } else {
            $mail->IsSMTP();
            // use SMTP directly
            if ($CFG->debug > 7) {
                echo '<pre>' . "\n";
                $mail->SMTPDebug = true;
            }
            $mail->Host = $CFG->smtphosts;
            // specify main and backup servers
            if ($CFG->smtpuser) {
                // Use SMTP authentication
                $mail->SMTPAuth = true;
                $mail->Username = $CFG->smtpuser;
                $mail->Password = $CFG->smtppass;
            }
        }
    }
    /* not here yet, leave it in just in case.
       // make up an email address for handling bounces
       if (!empty($CFG->handlebounces)) {
           $modargs = 'B'.base64_encode(pack('V',$user->ident)).substr(md5($user->email),0,16);
           $mail->Sender = generate_email_processing_address(0,$modargs);
       }
       else {
           $mail->Sender   =  $CFG->sysadminemail;
       }
       */
    $mail->Sender = $CFG->sysadminemail;
    // for elgg. delete if we change the above.
    // TODO add a preference for maildisplay
    if (is_string($from)) {
        // So we can pass whatever we want if there is need
        $mail->From = $CFG->noreplyaddress;
        $mail->FromName = $from;
    } else {
        if (empty($from)) {
            // make stuff up
            $mail->From = $CFG->sysadminemail;
            $mail->FromName = $CFG->sitename . ' ' . __gettext('Administrator');
        } else {
            if ($usetrueaddress and !empty($from->maildisplay)) {
                $mail->From = $from->email;
                $mail->FromName = $from->name;
            } else {
                $mail->From = $CFG->noreplyaddress;
                $mail->FromName = $from->name;
                if (empty($replyto)) {
                    $mail->AddReplyTo($CFG->noreplyaddress, __gettext('Do not reply'));
                }
            }
        }
    }
    if (!empty($replyto)) {
        $mail->AddReplyTo($replyto, $replytoname);
    }
    $mail->Subject = $textlib->substr(stripslashes($subject), 0, 900);
    $mail->AddAddress($user->email, $user->name);
    $mail->WordWrap = 79;
    // set word wrap
    if (!empty($from->customheaders)) {
        // Add custom headers
        if (is_array($from->customheaders)) {
            foreach ($from->customheaders as $customheader) {
                $mail->AddCustomHeader($customheader);
            }
        } else {
            $mail->AddCustomHeader($from->customheaders);
        }
    }
    if (!empty($from->priority)) {
        $mail->Priority = $from->priority;
    }
    //TODO add a user preference for this. right now just send plaintext
    $user->mailformat = 0;
    if ($messagehtml && $user->mailformat == 1) {
        // Don't ever send HTML to users who don't want it
        $mail->IsHTML(true);
        $mail->Encoding = 'quoted-printable';
        // Encoding to use
        $mail->Body = $messagehtml;
        $mail->AltBody = "\n{$messagetext}\n";
    } else {
        $mail->IsHTML(false);
        $mail->Body = "\n{$messagetext}\n";
    }
    if ($attachment && $attachname) {
        if (ereg("\\.\\.", $attachment)) {
            // Security check for ".." in dir path
            $mail->AddAddress($CFG->sysadminemail, $CFG->sitename . ' ' . __gettext('Administrator'));
            $mail->AddStringAttachment('Error in attachment.  User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
        } else {
            require_once $CFG->libdir . '/filelib.php';
            $mimetype = mimeinfo('type', $attachname);
            $mail->AddAttachment($attachment, $attachname, 'base64', $mimetype);
        }
    }
    if ($mail->Send()) {
        //        set_send_count($user); // later
        return true;
    } else {
        mtrace('ERROR: ' . $mail->ErrorInfo);
        return false;
    }
}
Example #6
0
 public function proc_upd()
 {
     $obj = ormPages::get(system::POST('obj_id'));
     $obj->tabuList('pseudo_url', 'h1', 'keywords', 'title', 'description', 'active', 'is_home_page', 'view_in_menu', 'view_submenu', 'in_search', 'in_index', 'in_new_window', 'other_link', 'img_act', 'img_no_act', 'img_h1');
     $obj->loadFromPost();
     // Публикация на сайте
     if (system::POST('publ', isBool)) {
         if ($obj->isInheritor('faq') && $obj->newVal('answer') == '') {
             ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), lang::get('FEEDBACK_MSG_3'));
             ui::selectErrorFields(array('select' => '', 'focus' => 'answer'));
         } else {
             $obj->active = 1;
         }
     }
     $obj_id = $obj->save();
     // Если объект не сохранился, выводим пользователю текст ошибки.
     if ($obj_id === false) {
         system::savePostToSession();
         ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), $obj->getErrorListText());
         ui::selectErrorFields($obj->getErrorFields());
         system::redirect('/feedback/message_upd/' . $_POST['obj_id']);
     }
     if (system::POST('send_to_email', isBool) && !$obj->send_answer_to_user && ($form_obj = ormObjects::get($obj->form_id))) {
         if ($form_obj->send_answer) {
             if ($obj->answer != '') {
                 $fields = $obj->getClass()->loadFields();
                 while (list($num, $field) = each($fields)) {
                     if (!empty($field['f_sname'])) {
                         page::assign($field['f_sname'], $obj->__get($field['f_sname']));
                     }
                 }
                 page::assign('site_name', domains::curDomain()->getSiteName());
                 page::assign('base_email', domains::curDomain()->getEmail());
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->answer_sender_address);
                 $mail->FromName = $this->parse($form_obj->answer_sender_name);
                 $mail->AddAddress($obj->email);
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->answer_subject);
                 $mail->Body = $this->parse($form_obj->answer_template);
                 $mail->Send();
                 // Помечаем, что ответ отправлен
                 $obj->send_answer_to_user = 1;
                 $obj->save();
                 ui::MessageBox(lang::get('FEEDBACK_MSG_1'), '');
             } else {
                 ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), lang::get('FEEDBACK_MSG_2'));
                 ui::selectErrorFields(array('select' => '', 'focus' => 'answer'));
             }
         }
     }
     // Если данные изменились корректно перенаправляем на соответствующию страницу
     if ($_POST['parram'] == 'apply') {
         system::redirect('/feedback/message_upd/' . $obj_id);
     } else {
         system::redirect('/feedback');
     }
 }
function fu_envia_clave($nom, $email, $email_ins, $user, $clave, $tipo)
{
    require_once "class.phpmailer.php";
    $mail = new phpmailer();
    $mail->From = "*****@*****.**";
    $mail->FromName = "Oficina Asesora de Sistemas";
    $mail->Host = "mail.udistrital.edu.co";
    $mail->Mailer = "smtp";
    $mail->SMTPAuth = true;
    $mail->Username = "******";
    $mail->Password = "******";
    $mail->Timeout = 120;
    $mail->Charset = "utf-8";
    $mail->IsHTML(false);
    if ($tipo == 4) {
        $tip = "Coordinador";
    } elseif ($tipo == 16) {
        $tip = "Decano";
    } elseif ($tipo == 24) {
        $tip = "Funcionario";
    } elseif ($tipo == 26) {
        $tip = "Proveedor";
    } elseif ($tipo == 30) {
        $tip = "Docente";
    } elseif ($tipo == 51) {
        $tip = "Estudiante";
    }
    //echo "tipo en fua_ ".$tipo; exit;
    $fecha = date("d-M-Y  h:i:s A");
    $comen = "Mensaje generado autom&aacute;ticamente por el servidor de la Oficina Asesora de Sistemas.\n";
    $comen .= "Este es su usuario y clave para ingresar al Sistema de Informaci&oacute;n C&oacute;ndor.\n\n";
    $comen .= "Por seguridad cambie la clave.\n\n";
    $sujeto = "Clave";
    $cuerpo = "Fecha de envio: " . $fecha . "\n\n";
    $cuerpo .= "Se&ntilde;or(a)      : " . $nom . "\n\n";
    $cuerpo .= $comen . "\n\n";
    $cuerpo .= "Tipo:           " . $tip . "\n";
    $cuerpo .= "Usuario:        " . $user . "\n";
    $cuerpo .= "Clave Acceso:   " . $clave . "\n";
    $mail->Body = $cuerpo;
    $mail->Subject = $sujeto;
    $mail->AddAddress($email);
    $mail->AddCC($email_ins);
    if (!$mail->Send()) {
        header("Location: {$redir}?error_login=16");
    } else {
        header("Location: {$redir}?error_login=18");
    }
    $mail->ClearAllRecipients();
}
Example #8
0
 public function sendmail($from, $to, $subject, $body, $altbody = null, $options = null, $attachments = null, $html = false)
 {
     if (!is_array($from)) {
         $from = array($from, $from);
     }
     $mail = new phpmailer();
     $mail->PluginDir = 'M/lib/phpmailer/';
     if ($this->getConfig('smtp')) {
         $mail->isSMTP();
         $mail->Host = $this->getConfig('smtphost');
         if ($this->getConfig('smtpusername')) {
             $mail->SMTPAuth = true;
             $mail->Port = $this->getConfig('smtpport') ? $this->getConfig('smtpport') : 25;
             $mail->SMTPDebug = $this->smtpdebug;
             $mail->Username = $this->getConfig('smtpusername');
             $mail->Password = $this->getConfig('smtppassword');
         }
     }
     $mail->CharSet = $this->getConfig('encoding');
     $mail->AddAddress($to);
     $mail->Subject = $subject;
     $mail->Body = $note . $body;
     $mail->AltBody = $altbody;
     if (!is_array($from)) {
         $from = array($from, $from);
     }
     $mail->From = $from[0];
     $mail->FromName = $from[1];
     if (key_exists('reply-to', $options)) {
         $mail->AddReplyTo($options['reply-to']);
         unset($options['reply-to']);
     }
     if (key_exists('Sender', $options)) {
         $mail->Sender = $options['Sender'];
     }
     if (null != $attachments) {
         if (!is_array($attachments)) {
             $attachments = array($attachments);
         }
         foreach ($attachments as $k => $v) {
             if (!$mail->AddAttachment($v, basename($v))) {
                 trigger_error("Attachment {$v} could not be added");
             }
         }
     }
     $mail->IsHTML($html);
     $result = $mail->send();
 }
Example #9
0
 function sendList($list)
 {
     // send email of message
     global $loader, $intl, $conf;
     $loader->import('saf.Ext.phpmailer');
     $mail = new phpmailer();
     $mail->IsMail();
     $mail->IsHTML(true);
     foreach ($list as $item) {
         if (strtoupper($item->type) == 'TASK') {
             $id = 'T' . $item->id;
         } elseif (strtoupper($item->type) == 'MESSAGE') {
             $id = 'M' . $item->id;
         } else {
             $id = strtoupper(substr($item->type, 0, 1)) . $item->id;
         }
         $mail->From = $conf['Messaging']['return_address'];
         //$mail->Subject = '[' . $this->id . '] ' . $this->subject;
         //$mail->Body = $this->body;
         $mail->AddAddress($item->address);
         if (defined('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_SUBJECT')) {
             $mail->Subject = $intl->get(constant('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_SUBJECT'), $item->struct);
         } else {
             $mail->Subject = '[' . $id . '] ' . $item->subject;
         }
         if (defined('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_BODY')) {
             $mail->Body = $intl->get(constant('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_BODY'), $item->struct);
         } else {
             $mail->Body = $item->body;
         }
         if ($item->priority == 'urgent' || $item->priority == 'high') {
             $mail->Priority = 1;
         } else {
             $mail->Priority = 3;
         }
         if (!$mail->Send()) {
             $this->error = $mail->ErrorInfo;
             return false;
         }
         $mail->ClearAddresses();
         $mail->ClearAttachments();
     }
     return true;
 }
Example #10
0
 function enviar($arguntos)
 {
     # code...
     $mail = new phpmailer(true);
     // the true param means it will throw exceptions on errors, which we need to catch
     $mail->IsSMTP();
     // telling the class to use SMTP
     $mail->Host = Host;
     // SMTP server
     $mail->SMTPDebug = 0;
     // enables SMTP debug information (for testing)
     $mail->IsHTML(true);
     $mail->SMTPAuth = SMTPAuth;
     // enable SMTP authentication
     $mail->SMTPSecure = SMTPSecure;
     // sets the prefix to the servier
     $mail->Port = Port;
     // set the SMTP port for the GMAIL server
     $mail->Username = Username;
     // GMAIL username
     $mail->Password = Password;
     // GMAIL password
     $mail->AddAddress($arguntos['email'], $arguntos['nomebusca']);
     if (AddReplyTo != '') {
         $mail->AddReplyTo(AddReplyTo);
     }
     $mail->Subject = $arguntos['Subject'];
     $mail->From = SetFromEmail;
     $mail->FromName = SetFromNome;
     $mail->Body = $arguntos['conteudo'];
     // optional - MsgHTML will create an alternate automatically
     // $mail->MsgHTML($arguntos['conteudo']);
     if ($mail->Send()) {
         echo "<p>Mensagem enviada com Sucesso!!!!</p>\n";
     }
 }
function SendMail($email, $name, $subject, $message)
{
    global $sockethost, $smtpauth, $smtpauthuser, $smtpauthpass, $socketfrom, $socketfromname, $socketreply, $socketreplyname;
    include 'class.phpmailer.php';
    $mail = new phpmailer();
    $mail->IsSMTP();
    $mail->Host = $sockethost;
    if ($smtpauth == 'TRUE') {
        $mail->SMTPAuth = true;
        $mail->Username = $smtpauthuser;
        $mail->Password = $smtpauthpass;
    }
    if (isset($_GET['caseid']) && ($_GET['caseid'] == 'NewTicket' || $_GET['caseid'] == 'view')) {
        $mail->From = $email;
        $mail->FromName = $name;
        $mail->AddReplyTo($email, $name);
    } else {
        $mail->From = $socketfrom;
        $mail->FromName = $socketfromname;
        $mail->AddReplyTo($socketreply, $socketreplyname);
    }
    $mail->IsHTML(False);
    $mail->Body = $message;
    $mail->Subject = $subject;
    if (isset($_GET['caseid']) && ($_GET['caseid'] == 'NewTicket' || $_GET['caseid'] == 'view')) {
        $mail->AddAddress($socketfrom, $socketfromname);
    } else {
        $mail->AddAddress($email, $name);
    }
    if (!$mail->Send()) {
        return 'Error: ' . $mail->ErrorInfo;
    } else {
        return 'Email Sent.';
    }
    $mail->ClearAddresses();
}
<?php

include_once($this->miConfigurador->getVariableConfiguracion("raizDocumento") . "/classes/mail/class.phpmailer.php");
include_once($this->miConfigurador->getVariableConfiguracion("raizDocumento") . "/classes/mail/class.smtp.php");

$mail = new phpmailer();
$mail->From = "*****@*****.**";
$mail->FromName = "Sistema de egresados Universidad Distrital Francisco Jose de Caldas";
$mail->Host = "mail.udistrital.edu.co";
$mail->Mailer = "smtp";
$mail->SMTPAuth = true;
$mail->Username = "******";
$mail->Password = "******";
$mail->Timeout = 120;
$mail->Charset = "utf-8";
$mail->IsHTML(false);


$fecha = date("d-M-Y  h:i:s A");
$comen = "Mensaje generado automaticamente por el servidor de la Oficina Asesora de Sistemas. \n";
$comen.= "Asignación o Cambio de segunda clave.\n\n";
$comen .= "Universidad Distrital Francisco José de Caldas PBX: (057) (1) 3239300 - 3238400 Sede principal: Carrera 7 No. 40B - 53 Oficina Asesora de Sistema Ext. 1112 \n";


$sujeto = "Datos de Acceso";
$cuerpo = "Fecha de envio: " . $fecha . "\n\n";

$cuerpo.="Estimado ".$nombre.":\n\n";
$cuerpo.="Usted ha solicitado generar o actualizar la segunda clave, el proceso se ha realizado exitosamente. \n\n";
$cuerpo.="Si usted no ha solicitado esta actualización, y ha recibido este correo, por favor comuniquese inmediatamente \n";
$cuerpo.="con la oficina asesora de sistema ya que puede ser victima de plagio.\n\n";
 $email = addslashes($_POST['email']);
 $q = "SELECT reg_id, email FROM user_info WHERE email='" . $email . "' ";
 $r = mysql_query($q) or die(mysql_error());
 $d = mysql_fetch_array($r);
 if (!mysql_num_rows($r)) {
     header("location:rlogin_a.php");
 } else {
     $reg_id = $d['reg_id'];
     $verify_id = md5(SHA1($email));
     include "phpmailer/class.phpmailer.php";
     include "phpmailer/class.smtp.php";
     $nits_rec2 = new phpmailer();
     $nits_rec2->IsSMTP();
     $nits_rec2->SMTPAuth = "true";
     $nits_rec2->SMTPDebug = 2;
     $nits_rec2->IsHTML(true);
     $nits_rec2->SMTPAuth = true;
     $nits_rec2->Username = "******";
     //to change email id from sending
     $nits_rec2->Password = "******";
     //its password
     $nits_rec2->SMTPSecure = 'tls';
     $nits_rec2->From = "*****@*****.**";
     $nits_rec2->FromName = "NIT Silchar";
     $nits_rec2->Subject = "Forget Password | Recruitment Registration, NIT Silchar!";
     $nits_rec2->Host = "172.16.30.72";
     // HOST SMTP OUT ADDRESS
     $nits_rec2->Port = 587;
     $body = "<html><head><link href='http://www.nits.ac.in/css/style.css' rel='stylesheet' type='text/css'/><link href='http://www.nits.ac.in/nits_rec/css/recruitment_form.css' rel='stylesheet' type='text/css'/><link href='http://old.nits.ac.in/nits_rec/css/final_form.css' rel='stylesheet' type='text/css'/><link href='http://fonts.googleapis.com/css?family=Marcellus' rel='stylesheet' type='text/css'><link href='http://fonts.googleapis.com/css?family=Ubuntu+Condensed' rel='stylesheet' type='text/css'></head><body><div id='wrapper' style='width:600px;'><div id='top' ><div id='logo' ><h1><a href='http://recruitment.nits.ac.in/non_faculty/'>National Institute of Technology Silchar</a></h1></div></div>";
     $body .= "<br /><br/><br/><b>To reset your password <a href='http://recruitment.nits.ac.in/non_faculty/forget_pwd.php?vid=" . $verify_id . "&rid=" . $reg_id . "'>CLICK HERE</a></b></div></body>";
     $nits_rec2->Mailer = "smtp";
 $enlace .= "&nombre=" . $egresados[$i]['nombre'];
 $enlace .= "&correo=" . $egresados[$i]['correo'];
 $enlace .= "&identificacion=" . $egresados[$i]['identificacion'];
 $enlace .= "&tiempo=" . $tiempo;
 $enlace = $this->miConfigurador->fabricaConexiones->crypto->codificar_url($enlace, $directorio);
 $mail = new phpmailer();
 $mail->From = "*****@*****.**";
 $mail->FromName = "Sistema de egresados Universidad Distrital Francisco Jose de Caldas";
 $mail->Host = "mail.udistrital.edu.co";
 $mail->Mailer = "smtp";
 $mail->SMTPAuth = true;
 $mail->Username = "******";
 $mail->Password = "******";
 $mail->Timeout = 120;
 $mail->Charset = "utf-8";
 $mail->IsHTML(TRUE);
 $asunto = "Datos de acceso";
 $html = "<div align='center'><img src='" . $rutaBloque . "/css/images/ud.jpg'></div>";
 $html .= "Respetado Destinatario(a) <br><br>";
 $html .= "Reciba un cordial saludo, <br><br>";
 $html .= "Nos permitimos informarle que su correo electrónico aparece asociado a la información de " . $egresados[$i]['nombre'] . ", en la base de datos del Sistema de Egresados de la Universidad Distrital Francisco José de Caldas.<br><br>";
 $html .= "Si usted, como propietario de la cuenta de correo, identifica que la información relacionada es errónea, por favor omita el resto del contenido del mensaje.<br><br>";
 $html .= "Si por el contrario, la información relacionada coincide con sus nombres y apellidos, lo invitamos a leer la siguiente información de su interés:<br><br> ";
 $html .= "<strong><b>Portal de Egresados Universidad Distrital Francisco José de Caldas</b></strong><br><hr><br>";
 $html .= "<blink><b>AVISO LEGAL</b>:</blink> La Universidad Distrital Francisco José de Caldas, informa que a través del presente mensaje solo autoriza el ingreso al Portal de Egresados a " . $egresados[$i]['nombre'] . ". El no acatamiento de esta autorización puede acarrear la consecuencias legales que se mencionan en la Ley 1273 del 5 de Enero de 2009 y las demás que apliquen. <br><br>";
 $html .= "Respetado egresado:<br><br>";
 $html .= "A través del siguiente enlace podrá registrar las credenciales de acceso al Portal de Egresados de la Universidad Distrital Francisco José de Caldas.<br><br><a href='" . $enlace . "'>Acceso al portal de egresados</a><br><br>";
 $html .= "La primera vez que acceda al Portal, se le solicitará la autorización para el tratamiento de datos, conforme a los estipulado en la Ley 1581 de 2012 y el decreto reglamentario 1377 de 2013. Además, para favorecer la aplicación de medidas de protección de la identidad, deberá registrar datos de contacto que permitan su posterior verificación.<br><br>";
 $html .= "En caso de alguna observación por favor dirigir un correo a <a href='*****@*****.**'>computo@udistrital.edu.co</a> .<br><br>";
 $html .= "Este mensaje se ha generado automaticamente por el servidor de Asignación de clave de acceso al Sistema de Egresados. Se solicita no responder al remitente.<br><br>";
 $html .= "<br><hr><br>";
 /**
  * Send a confirmation e-mail to the address specified in the form,
  * if any.
  * @param $id
  * @param unknown_type $email
  * @return unknown
  */
 function sendMail($feedId, $email)
 {
     global $_CONFIG, $objDatabase, $_ARRAYLANG, $objInit;
     $feedId = intval($feedId);
     $languageId = null;
     // Get the user ID and entry information
     $objResult = $objDatabase->Execute("\n            SELECT addedby, title, language\n              FROM " . DBPREFIX . "module_directory_dir\n             WHERE id='{$feedId}'");
     if ($objResult && !$objResult->EOF) {
         $userId = $objResult->fields['addedby'];
         $feedTitle = $objResult->fields['title'];
         $languageId = $objResult->fields['language'];
     }
     // Get user data
     if (is_numeric($userId)) {
         $objFWUser = new \FWUser();
         if ($objFWUser->objUser->getUser($userId)) {
             $userMail = $objFWUser->objUser->getEmail();
             $userFirstname = $objFWUser->objUser->getProfileAttribute('firstname');
             $userLastname = $objFWUser->objUser->getProfileAttribute('lastname');
             $userUsername = $objFWUser->objUser->getUsername();
         }
     }
     if (!empty($email)) {
         $sendTo = $email;
         $mailId = 2;
     } else {
         // FIXED:  The mail addresses may *both* be empty!
         // Adding the entry was sucessful, however.  So we can probably assume
         // that it was a success anyway?
         // Added:
         if (empty($userMail)) {
             return true;
         }
         // ...and a boolean return value below.
         $sendTo = $userMail;
         $mailId = 1;
     }
     //get mail content n title
     $objResult = $objDatabase->Execute("\n            SELECT title, content\n              FROM " . DBPREFIX . "module_directory_mail\n             WHERE id='{$mailId}'");
     if ($objResult && !$objResult->EOF) {
         $subject = $objResult->fields['title'];
         $message = $objResult->fields['content'];
     }
     if ($objInit->mode == 'frontend') {
         $link = "http://" . $_CONFIG['domainUrl'] . CONTREXX_SCRIPT_PATH . "?section=Directory&cmd=detail&id=" . $feedId;
     } else {
         $link = "http://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageParameter($languageId, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . "?section=Directory&cmd=detail&id=" . $feedId;
     }
     // replace placeholders
     $array_1 = array('[[USERNAME]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[TITLE]]', '[[LINK]]', '[[URL]]', '[[DATE]]');
     $array_2 = array($userUsername, $userFirstname, $userLastname, $feedTitle, $link, $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET, date(ASCMS_DATE_FORMAT));
     $subject = str_replace($array_1, $array_2, $subject);
     $message = str_replace($array_1, $array_2, $message);
     $sendTo = explode(';', $sendTo);
     if (@\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && @\Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             $arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']);
             if ($arrSmtp !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->From = $_CONFIG['coreAdminEmail'];
         $objMail->FromName = $_CONFIG['coreAdminName'];
         $objMail->AddReplyTo($_CONFIG['coreAdminEmail']);
         $objMail->Subject = $subject;
         $objMail->IsHTML(false);
         $objMail->Body = $message;
         foreach ($sendTo as $mailAdress) {
             $objMail->ClearAddresses();
             $objMail->AddAddress($mailAdress);
             $objMail->Send();
         }
     }
     return true;
 }
Example #16
0
 /**
  * Send confirmation email.
  *
  * @access      private
  * @param       string      $recipient      recipient
  * @param       array       $arrMail        title and content
  */
 private function sendConfirmationMail($recipient, $arrMail)
 {
     global $_ARRAYLANG, $_CONFIG;
     $objPHPMailer = new \phpmailer();
     if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
             $objPHPMailer->IsSMTP();
             $objPHPMailer->Host = $arrSmtp['hostname'];
             $objPHPMailer->Port = $arrSmtp['port'];
             $objPHPMailer->SMTPAuth = true;
             $objPHPMailer->Username = $arrSmtp['username'];
             $objPHPMailer->Password = $arrSmtp['password'];
         }
     }
     $objPHPMailer->CharSet = CONTREXX_CHARSET;
     $objPHPMailer->IsHTML(true);
     $objPHPMailer->Subject = $arrMail['title'];
     $objPHPMailer->SetFrom($_CONFIG['contactFormEmail'], $_CONFIG['domainUrl']);
     $objPHPMailer->AddAddress($recipient);
     $objPHPMailer->Body = $arrMail['content'];
     $objPHPMailer->Send();
 }
Example #17
0
 function send()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     $this->_objTpl->setTemplate($this->pageContent);
     // Initialize variables
     $code = substr(md5(rand()), 1, 10);
     $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Ecard', 'show', '', array('code' => $code))->toString();
     // Initialize POST variables
     $id = intval($_POST['selectedEcard']);
     $message = contrexx_addslashes($_POST['ecardMessage']);
     $recipientSalutation = contrexx_stripslashes($_POST['ecardRecipientSalutation']);
     $senderName = contrexx_stripslashes($_POST['ecardSenderName']);
     $senderEmail = \FWValidator::isEmail($_POST['ecardSenderEmail']) ? $_POST['ecardSenderEmail'] : '';
     $recipientName = contrexx_stripslashes($_POST['ecardRecipientName']);
     $recipientEmail = \FWValidator::isEmail($_POST['ecardRecipientEmail']) ? $_POST['ecardRecipientEmail'] : '';
     if (empty($senderEmail) || empty($recipientEmail)) {
         $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_SENDING_ERROR']));
         return false;
     }
     $query = "\n            SELECT `setting_name`, `setting_value`\n              FROM " . DBPREFIX . "module_ecard_settings";
     $objResult = $objDatabase->Execute($query);
     while (!$objResult->EOF) {
         switch ($objResult->fields['setting_name']) {
             case 'validdays':
                 $validdays = $objResult->fields['setting_value'];
                 break;
                 // Never used
                 //                case 'greetings':
                 //                    $greetings = $objResult->fields['setting_value'];
                 //                    break;
             // Never used
             //                case 'greetings':
             //                    $greetings = $objResult->fields['setting_value'];
             //                    break;
             case 'subject':
                 $subject = $objResult->fields['setting_value'];
                 break;
             case 'emailText':
                 $emailText = strip_tags($objResult->fields['setting_value']);
                 break;
         }
         $objResult->MoveNext();
     }
     $timeToLife = $validdays * 86400;
     // Replace placeholders with used in notification mail with user data
     $emailText = str_replace('[[ECARD_RECIPIENT_SALUTATION]]', $recipientSalutation, $emailText);
     $emailText = str_replace('[[ECARD_RECIPIENT_NAME]]', $recipientName, $emailText);
     $emailText = str_replace('[[ECARD_RECIPIENT_EMAIL]]', $recipientEmail, $emailText);
     $emailText = str_replace('[[ECARD_SENDER_NAME]]', $senderName, $emailText);
     $emailText = str_replace('[[ECARD_SENDER_EMAIL]]', $senderEmail, $emailText);
     $emailText = str_replace('[[ECARD_VALID_DAYS]]', $validdays, $emailText);
     $emailText = str_replace('[[ECARD_URL]]', $url, $emailText);
     $body = $emailText;
     // Insert ecard to DB
     $query = "\n            INSERT INTO `" . DBPREFIX . "module_ecard_ecards` (\n                code, date, TTL, salutation,\n                senderName, senderEmail,\n                recipientName, recipientEmail,\n                message\n            ) VALUES (\n                '" . $code . "',\n                '" . time() . "',\n                '" . $timeToLife . "',\n                '" . addslashes($recipientSalutation) . "',\n                '" . addslashes($senderName) . "',\n                '" . $senderEmail . "',\n                '" . addslashes($recipientName) . "',\n                '" . $recipientEmail . "',\n                '" . $message . "');";
     if ($objDatabase->Execute($query)) {
         $query = "\n                SELECT setting_value\n                  FROM " . DBPREFIX . "module_ecard_settings\n                 WHERE setting_name='motive_{$id}'";
         $objResult = $objDatabase->SelectLimit($query, 1);
         // Copy motive to new file with $code as filename
         $fileExtension = preg_replace('/^.+(\\.[^\\.]+)$/', '$1', $objResult->fields['setting_value']);
         $fileName = $objResult->fields['setting_value'];
         $objFile = new \File();
         if ($objFile->copyFile(ASCMS_ECARD_OPTIMIZED_PATH . '/', $fileName, ASCMS_ECARD_SEND_ECARDS_PATH . '/', $code . $fileExtension)) {
             $objMail = new \phpmailer();
             // Check e-mail settings
             if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
                 $objSmtpSettings = new \SmtpSettings();
                 if (($arrSmtp = $objSmtpSettings->getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                     $objMail->IsSMTP();
                     $objMail->Host = $arrSmtp['hostname'];
                     $objMail->Port = $arrSmtp['port'];
                     $objMail->SMTPAuth = true;
                     $objMail->Username = $arrSmtp['username'];
                     $objMail->Password = $arrSmtp['password'];
                 }
             }
             // Send notification mail to ecard-recipient
             $objMail->CharSet = CONTREXX_CHARSET;
             $objMail->SetFrom($senderEmail, $senderName);
             $objMail->Subject = $subject;
             $objMail->IsHTML(false);
             $objMail->Body = $body;
             $objMail->AddAddress($recipientEmail);
             if ($objMail->Send()) {
                 $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_HAS_BEEN_SENT']));
             } else {
                 $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_MAIL_SENDING_ERROR']));
             }
         }
     } else {
         $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_SENDING_ERROR']));
     }
 }
Example #18
0
 /**
  * @return void
  * @desc Sends a notification email to the administrator
  */
 function sendNotificationEmail($forename, $name, $comment, $email = null)
 {
     global $_ARRAYLANG, $_CONFIG;
     $message = $_ARRAYLANG['TXT_CHECK_GUESTBOOK_ENTRY'] . "\n\n";
     $message .= $_ARRAYLANG['TXT_ENTRY_READS'] . "\n" . $forename . " " . $name . "\n" . html_entity_decode($comment, ENT_QUOTES, CONTREXX_CHARSET);
     $mailto = $_CONFIG['coreAdminEmail'];
     $subject = $_ARRAYLANG['TXT_NEW_GUESTBOOK_ENTRY'] . " " . $_CONFIG['domainUrl'];
     if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $from = isset($email) ? $email : $mailto;
         $objMail->SetFrom($from);
         $objMail->Subject = $subject;
         $objMail->IsHTML(false);
         $objMail->Body = $message;
         $objMail->AddAddress($mailto);
         if ($objMail->Send()) {
             return true;
         }
     }
     return false;
 }
Example #19
0
 function sendMessage($id)
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG;
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     //get erntry
     $this->getEntries('', 'id', $id);
     if (isset($id) && count($this->entries) != 0) {
         //get search
         $this->getSearch();
         //get navigatin
         $this->getNavigation($this->entries[$id]['catid']);
         if ($_POST['title'] != '' && $_POST['message'] != '') {
             //create mail
             $sendTo = $this->entries[$id]['email'];
             $fromName = $_POST['name'];
             $fromMail = $_POST['email'];
             $subject = $_POST['title'];
             $newPrice = $_POST['newprice'] != '' ? "\n\n" . $_ARRAYLANG['TXT_PRICE_EXPECTATION'] . "\n" . $_POST['newprice'] : '';
             $oldPrice = $_POST['price'] != '' ? "\n\n" . $_ARRAYLANG['TXT_MARKET_MESSAGE_PRICE'] . "\n" . $_POST['price'] : '';
             $message = $_POST['message'] . $oldPrice . $newPrice;
             if (\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
                 $objMail = new \phpmailer();
                 if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
                     if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                         $objMail->IsSMTP();
                         $objMail->Host = $arrSmtp['hostname'];
                         $objMail->Port = $arrSmtp['port'];
                         $objMail->SMTPAuth = true;
                         $objMail->Username = $arrSmtp['username'];
                         $objMail->Password = $arrSmtp['password'];
                     }
                 }
                 $objMail->CharSet = CONTREXX_CHARSET;
                 $objMail->From = $fromMail;
                 $objMail->FromName = $fromName;
                 $objMail->AddReplyTo($fromMail);
                 $objMail->Subject = $subject;
                 $objMail->IsHTML(false);
                 $objMail->Body = $message;
                 $objMail->AddAddress($sendTo);
                 $objMail->Send();
             }
             // set variables
             $this->_objTpl->setVariable(array('MARKET_TITLE' => $_ARRAYLANG['TXT_MARKET_MESSAGE_SUCCESS_TITLE'], 'MARKET_MSG_SEND' => $_ARRAYLANG['TXT_MARKET_MESSAGE_SUCCESS_BODY'], 'TXT_MARKET_BACK' => $_CORELANG['TXT_BACK']));
         }
     } else {
         \Cx\Core\Csrf\Controller\Csrf::header('Location: ?section=Market');
     }
 }
 /**
  * Устанавливает режим отправки письма как Text(Plain)
  *
  */
 public function setPlain()
 {
     $this->oMailer->IsHTML(false);
 }
 function sendMail()
 {
     global $_ARRAYLANG, $_CONFIG;
     if (\Env::get('ClassLoader')->loadFile(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCorePath() . '/SmtpSettings.class.php')) {
             $arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']);
             if ($arrSmtp !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
         $objMail->Subject = $this->strTitle;
         $objMail->IsHTML(false);
         $objMail->Body = $this->strTemplate;
         foreach ($this->arrRecipients as $key => $strMailAdress) {
             if (!empty($strMailAdress)) {
                 $objMail->AddAddress($strMailAdress);
                 $objMail->Send();
                 $objMail->ClearAddresses();
             }
         }
     }
 }
 /**
  * Reports a possible intrusion attempt to the administrator
  * @param   $type    The type of intrusion attempt to report.
  * @param   $file    The file requesting the report (defaults to "Filename not available")
  * @param   $line    The line number requesting the report (defaults to "Linenumber not available")
  **/
 function reportIntrusion($type, $file = "Filename not available", $line = "Linenumber not available")
 {
     $objDatabase = \Env::get('db');
     $config = \Env::get('config');
     $remoteaddr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "Not set";
     $httpxforwardedfor = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : "Not set";
     $httpvia = isset($_SERVER['HTTP_VIA']) ? $_SERVER['HTTP_VIA'] : "Not set";
     $httpclientip = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : "Not set";
     $gethostbyname = gethostbyname($remoteaddr);
     if ($gethostbyname == $remoteaddr) {
         $gethostbyname = "No matching hostname";
     }
     // Add all the user's info to $user
     $user = "******" . "HTTP_X_FORWARDED_FOR : {$httpxforwardedfor}\r\n" . "HTTP_VIA : {$httpvia}\r\n" . "HTTP_CLIENT_IP : {$httpclientip}\r\n" . "GetHostByName : {$gethostbyname}\r\n";
     // Add all requested information
     foreach ($this->criticalServerVars as $serverVar) {
         $_SERVERlite[$serverVar] = $_SERVER[$serverVar];
     }
     $httpheaders = function_exists('getallheaders') ? getallheaders() : null;
     $gpcs = "";
     $gpcs .= $this->getRequestInfo($httpheaders, "HTTP HEADER");
     $gpcs .= $this->getRequestInfo($_REQUEST, "REQUEST");
     $gpcs .= $this->getRequestInfo($_GET, "GET");
     $gpcs .= $this->getRequestInfo($_POST, "POST");
     $gpcs .= $this->getRequestInfo($_SERVERlite, "SERVER");
     $gpcs .= $this->getRequestInfo($_COOKIE, "COOKIE");
     $gpcs .= $this->getRequestInfo($_FILES, "FILES");
     $gpcs .= $this->getRequestInfo($_SESSION, "SESSION");
     // Get the data to insert in the database
     $cdate = time();
     $dbuser = htmlspecialchars(addslashes($user), ENT_QUOTES, CONTREXX_CHARSET);
     $dbuser = contrexx_raw2db($dbuser);
     $dbgpcs = htmlspecialchars(addslashes($gpcs), ENT_QUOTES, CONTREXX_CHARSET);
     $dbgpcs = contrexx_raw2db($dbgpcs);
     $where = addslashes("{$file} : {$line}");
     $where = contrexx_raw2db($where);
     // Insert the intrusion in the database
     $objDatabase->Execute("INSERT INTO " . DBPREFIX . "ids (timestamp, type, remote_addr, http_x_forwarded_for, http_via, user, gpcs, file)\n                VALUES(" . $cdate . ", '" . $type . "', '" . $remoteaddr . "', '" . $httpxforwardedfor . "', '" . $httpvia . "', '" . $dbuser . "', '" . $dbgpcs . "', '" . $where . "')");
     // The headers for the e-mail
     $emailto = $config['coreAdminName'] . " <" . $config['coreAdminEmail'] . ">";
     // The message to send
     $message = "DATE : {$cdate}\r\nFILE : {$where}\r\n\r\n{$user}\r\n\r\n{$gpcs}";
     // Send the e-mail to the administrator
     if (\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($config['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($config['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($config['coreAdminEmail'], $config['coreAdminName']);
         $objMail->Subject = $_SERVER['HTTP_HOST'] . " : {$type}";
         $objMail->IsHTML(false);
         $objMail->Body = $message;
         $objMail->AddAddress($emailto);
         $objMail->Send();
     }
 }
Example #23
0
 /**
  * Sends an email with the contact details to the responsible persons
  *
  * This methode sends an email to all email addresses that are defined in the
  * option "Receiver address(es)" of the requested contact form.
  * @access private
  * @global array
  * @global array
  * @param array Details of the contact request
  * @see _getEmailAdressOfString(), phpmailer::From, phpmailer::FromName, phpmailer::AddReplyTo(), phpmailer::Subject, phpmailer::IsHTML(), phpmailer::Body, phpmailer::AddAddress(), phpmailer::Send(), phpmailer::ClearAddresses()
  */
 private function sendMail($arrFormData)
 {
     global $_ARRAYLANG, $_CONFIG;
     $plaintextBody = '';
     $replyAddress = '';
     $firstname = '';
     $lastname = '';
     $senderName = '';
     $isHtml = $arrFormData['htmlMail'] == 1 ? true : false;
     // stop send process in case no real data had been submitted
     if (!isset($arrFormData['data']) && !isset($arrFormData['uploadedFiles'])) {
         return false;
     }
     // check if we shall send the email as multipart (text/html)
     if ($isHtml) {
         // setup html mail template
         $objTemplate = new \Cx\Core\Html\Sigma('.');
         $objTemplate->setErrorHandling(PEAR_ERROR_DIE);
         $objTemplate->setTemplate($arrFormData['mailTemplate']);
         $objTemplate->setVariable(array('DATE' => date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']), 'HOSTNAME' => contrexx_raw2xhtml($arrFormData['meta']['host']), 'IP_ADDRESS' => contrexx_raw2xhtml($arrFormData['meta']['ipaddress']), 'BROWSER_LANGUAGE' => contrexx_raw2xhtml($arrFormData['meta']['lang']), 'BROWSER_VERSION' => contrexx_raw2xhtml($arrFormData['meta']['browser'])));
     }
     // TODO: check if we have to excape $arrRecipients later in the code
     $arrRecipients = $this->getRecipients(intval($_GET['cmd']));
     // calculate the longest field label.
     // this will be used to correctly align all user submitted data in the plaintext e-mail
     // TODO: check if the label of upload-fields are taken into account as well
     $maxlength = 0;
     foreach ($arrFormData['fields'] as $arrField) {
         $length = strlen($arrField['lang'][FRONTEND_LANG_ID]['name']);
         $maxlength = $maxlength < $length ? $length : $maxlength;
     }
     // try to fetch a user submitted e-mail address to which we will send a copy to
     if (!empty($arrFormData['fields'])) {
         foreach ($arrFormData['fields'] as $fieldId => $arrField) {
             // check if field validation is set to e-mail
             if ($arrField['check_type'] == '2') {
                 $mail = trim($arrFormData['data'][$fieldId]);
                 if (\FWValidator::isEmail($mail)) {
                     $replyAddress = $mail;
                     break;
                 }
             }
             if ($arrField['type'] == 'special') {
                 switch ($arrField['special_type']) {
                     case 'access_firstname':
                         $firstname = trim($arrFormData['data'][$fieldId]);
                         break;
                     case 'access_lastname':
                         $lastname = trim($arrFormData['data'][$fieldId]);
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     if ($arrFormData['useEmailOfSender'] == 1 && (!empty($firstname) || !empty($lastname))) {
         $senderName = trim($firstname . ' ' . $lastname);
     } else {
         $senderName = $_CONFIG['coreGlobalPageTitle'];
     }
     // a recipient mail address which has been picked by sender
     $chosenMailRecipient = null;
     // fill the html and plaintext body with the submitted form data
     foreach ($arrFormData['fields'] as $fieldId => $arrField) {
         if ($fieldId == 'unique_id') {
             //generated for uploader. no interesting mail content.
             continue;
         }
         $htmlValue = '';
         $plaintextValue = '';
         $textAreaKeys = array();
         switch ($arrField['type']) {
             case 'label':
             case 'fieldset':
                 // TODO: parse TH row instead
             // TODO: parse TH row instead
             case 'horizontalLine':
                 // TODO: add visual horizontal line
                 // we need to use a 'continue 2' here to first break out of the switch and then move over to the next iteration of the foreach loop
                 continue 2;
                 break;
             case 'file':
             case 'multi_file':
                 $htmlValue = "";
                 $plaintextValue = "";
                 if (isset($arrFormData['uploadedFiles'][$fieldId])) {
                     $htmlValue = "<ul>";
                     foreach ($arrFormData['uploadedFiles'][$fieldId] as $file) {
                         $htmlValue .= "<li><a href='" . ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . \Env::get('cx')->getWebsiteOffsetPath() . contrexx_raw2xhtml($file['path']) . "' >" . contrexx_raw2xhtml($file['name']) . "</a></li>";
                         $plaintextValue .= ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . \Env::get('cx')->getWebsiteOffsetPath() . $file['path'] . "\r\n";
                     }
                     $htmlValue .= "</ul>";
                 }
                 break;
             case 'checkbox':
                 $plaintextValue = !empty($arrFormData['data'][$fieldId]) ? $_ARRAYLANG['TXT_CONTACT_YES'] : $_ARRAYLANG['TXT_CONTACT_NO'];
                 $htmlValue = $plaintextValue;
                 break;
             case 'recipient':
                 // TODO: check for XSS
                 $plaintextValue = $arrRecipients[$arrFormData['data'][$fieldId]]['lang'][FRONTEND_LANG_ID];
                 $htmlValue = $plaintextValue;
                 $chosenMailRecipient = $arrRecipients[$arrFormData['data'][$fieldId]]['email'];
                 break;
             case 'textarea':
                 //we need to know all textareas - they're indented differently then the rest of the other field types
                 $textAreaKeys[] = $fieldId;
             default:
                 $plaintextValue = isset($arrFormData['data'][$fieldId]) ? $arrFormData['data'][$fieldId] : '';
                 $htmlValue = contrexx_raw2xhtml($plaintextValue);
                 break;
         }
         $fieldLabel = $arrField['lang'][FRONTEND_LANG_ID]['name'];
         // try to fetch an e-mail address from submitted form date in case we were unable to fetch one from an input type with e-mail validation
         if (empty($replyAddress)) {
             $mail = $this->_getEmailAdressOfString($plaintextValue);
             if (\FWValidator::isEmail($mail)) {
                 $replyAddress = $mail;
             }
         }
         // parse html body
         if ($isHtml) {
             if (!empty($htmlValue)) {
                 if ($objTemplate->blockExists('field_' . $fieldId)) {
                     // parse field specific template block
                     $objTemplate->setVariable(array('FIELD_' . $fieldId . '_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_' . $fieldId . '_VALUE' => $htmlValue));
                     $objTemplate->parse('field_' . $fieldId);
                 } elseif ($objTemplate->blockExists('form_field')) {
                     // parse regular field template block
                     $objTemplate->setVariable(array('FIELD_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_VALUE' => $htmlValue));
                     $objTemplate->parse('form_field');
                 }
             } elseif ($objTemplate->blockExists('field_' . $fieldId)) {
                 // hide field specific template block, if present
                 $objTemplate->hideBlock('field_' . $fieldId);
             }
         }
         // parse plaintext body
         $tabCount = $maxlength - strlen($fieldLabel);
         $tabs = $tabCount == 0 ? 1 : $tabCount + 1;
         // TODO: what is this all about? - $value is undefined
         if ($arrFormData['fields'][$fieldId]['type'] == 'recipient') {
             $value = $arrRecipients[$value]['lang'][FRONTEND_LANG_ID];
         }
         if (in_array($fieldId, $textAreaKeys)) {
             // we're dealing with a textarea, don't indent value
             $plaintextBody .= $fieldLabel . ":\n" . $plaintextValue . "\n";
         } else {
             $plaintextBody .= $fieldLabel . str_repeat(" ", $tabs) . ": " . $plaintextValue . "\n";
         }
     }
     $arrSettings = $this->getSettings();
     // TODO: this is some fixed plaintext message data -> must be ported to html body
     $message = $_ARRAYLANG['TXT_CONTACT_TRANSFERED_DATA_FROM'] . " " . $_CONFIG['domainUrl'] . "\n\n";
     if ($arrSettings['fieldMetaDate']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_DATE'] . " " . date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']) . "\n\n";
     }
     $message .= $plaintextBody . "\n\n";
     if ($arrSettings['fieldMetaHost']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_HOSTNAME'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['host']) . "\n";
     }
     if ($arrSettings['fieldMetaIP']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_IP_ADDRESS'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['ipaddress']) . "\n";
     }
     if ($arrSettings['fieldMetaLang']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_LANGUAGE'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['lang']) . "\n";
     }
     $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_VERSION'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['browser']) . "\n";
     if (@(include_once \Env::get('cx')->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once \Env::get('cx')->getCodeBaseCorePath() . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->From = $_CONFIG['coreAdminEmail'];
         $objMail->FromName = $senderName;
         if (!empty($replyAddress)) {
             $objMail->AddReplyTo($replyAddress);
             if ($arrFormData['sendCopy'] == 1) {
                 $objMail->AddAddress($replyAddress);
             }
             if ($arrFormData['useEmailOfSender'] == 1) {
                 $objMail->From = $replyAddress;
             }
         }
         $objMail->Subject = $arrFormData['subject'];
         if ($isHtml) {
             $objMail->Body = $objTemplate->get();
             $objMail->AltBody = $message;
         } else {
             $objMail->IsHTML(false);
             $objMail->Body = $message;
         }
         // attach submitted files to email
         if (count($arrFormData['uploadedFiles']) > 0 && $arrFormData['sendAttachment'] == 1) {
             foreach ($arrFormData['uploadedFiles'] as $arrFilesOfField) {
                 foreach ($arrFilesOfField as $file) {
                     $objMail->AddAttachment(\Env::get('cx')->getWebsiteDocumentRootPath() . $file['path'], $file['name']);
                 }
             }
         }
         if ($chosenMailRecipient !== null) {
             if (!empty($chosenMailRecipient)) {
                 $objMail->AddAddress($chosenMailRecipient);
                 $objMail->Send();
                 $objMail->ClearAddresses();
             }
         } else {
             foreach ($arrFormData['emails'] as $sendTo) {
                 if (!empty($sendTo)) {
                     $objMail->AddAddress($sendTo);
                     $objMail->Send();
                     $objMail->ClearAddresses();
                 }
             }
         }
     }
     return true;
 }
        if ($li['DIFERENCIA'] > 0) {
            $cuerpo .= "FALTANTE \$" . $li['DIFERENCIA'] . "</td>";
        } else {
            $cuerpo .= "EXCEDENTE \$" . $li['DIFERENCIA'] * -1 . "</td>";
        }
    }
    $cuerpo .= "</tr>";
}
$cuerpo .= "</table>";
//Prueba
//$cuerpo .="<h1>ESTE CORREO ES UNA PRUEBA POR FAVOR NO LA TOME EN CUENTA</h1>";
//Cuerpo del mensaje
$mail->Body = $cuerpo;
//Este el asunto
$mail->Subject = $tema;
$mail->IsHTML(true);
//Correos
$mail->AddAddress("*****@*****.**");
$mail->AddAddress("*****@*****.**");
//Correo Bienestar
$mail->AddAddress('*****@*****.**');
//correo prueba
//$mail->AddAddress("*****@*****.**");
/*
$mail->AddAddress("*****@*****.**");
$mail->AddAddress("*****@*****.**");
$mail->AddAddress("*****@*****.**");
*/
if (!$mail->Send()) {
    echo $this->lenguaje->getCadena("errorMail") . "<br>";
    echo 'Mailer Error: ' . $mail->ErrorInfo;
/** 
 * Always use this function for all emails to users
 * 
 * @param object $userto user object to send email to. must contain firstname,lastname,preferredname,email
 * @param object $userfrom user object to send email from. If null, email will come from mahara
 * @param string $subject email subject
 * @param string $messagetext text version of email
 * @param string $messagehtml html version of email (will send both html and text)
 * @param array  $customheaders email headers
 * @throws EmailException
 * @throws EmailDisabledException
 */
function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml = '', $customheaders = null)
{
    global $IDPJUMPURL;
    static $mnetjumps = array();
    if (!get_config('sendemail')) {
        // You can entirely disable Mahara from sending any e-mail via the
        // 'sendemail' configuration variable
        return true;
    }
    if (empty($userto)) {
        throw new InvalidArgumentException("empty user given to email_user");
    }
    if (!($mailinfo = can_receive_email($userto))) {
        throw new EmailDisabledException("email for this user has been disabled");
    }
    // If the user is a remote xmlrpc user, trawl through the email text for URLs
    // to our wwwroot and modify the url to direct the user's browser to login at
    // their home site before hitting the link on this site
    if (!empty($userto->mnethostwwwroot) && !empty($userto->mnethostapp)) {
        require_once get_config('docroot') . 'auth/xmlrpc/lib.php';
        // Form the request url to hit the idp's jump.php
        if (isset($mnetjumps[$userto->mnethostwwwroot])) {
            $IDPJUMPURL = $mnetjumps[$userto->mnethostwwwroot];
        } else {
            $mnetjumps[$userto->mnethostwwwroot] = $IDPJUMPURL = PluginAuthXmlrpc::get_jump_url_prefix($userto->mnethostwwwroot, $userto->mnethostapp);
        }
        $wwwroot = get_config('wwwroot');
        $messagetext = preg_replace_callback('%(' . $wwwroot . '([\\w_:\\?=#&@/;.~-]*))%', 'localurl_to_jumpurl', $messagetext);
        $messagehtml = preg_replace_callback('%href=["\'`](' . $wwwroot . '([\\w_:\\?=#&@/;.~-]*))["\'`]%', 'localurl_to_jumpurl', $messagehtml);
    }
    require_once 'phpmailer/class.phpmailer.php';
    $mail = new phpmailer();
    // Leaving this commented out - there's no reason for people to know this
    //$mail->Version = 'Mahara ' . get_config('release');
    $mail->PluginDir = get_config('libroot') . 'phpmailer/';
    $mail->CharSet = 'UTF-8';
    $smtphosts = get_config('smtphosts');
    if ($smtphosts == 'qmail') {
        // use Qmail system
        $mail->IsQmail();
    } else {
        if (empty($smtphosts)) {
            // use PHP mail() = sendmail
            $mail->IsMail();
        } else {
            $mail->IsSMTP();
            // use SMTP directly
            $mail->Host = get_config('smtphosts');
            if (get_config('smtpuser')) {
                // Use SMTP authentication
                $mail->SMTPAuth = true;
                $mail->Username = get_config('smtpuser');
                $mail->Password = get_config('smtppass');
            }
        }
    }
    if (get_config('bounces_handle') && isset($mailinfo->owner)) {
        $mail->Sender = generate_email_processing_address($mailinfo->owner, $userto);
    }
    if (empty($userfrom) || $userfrom->email == get_config('noreplyaddress')) {
        if (empty($mail->Sender)) {
            $mail->Sender = get_config('noreplyaddress');
        }
        $mail->From = get_config('noreplyaddress');
        $mail->FromName = isset($userfrom->id) ? display_name($userfrom, $userto) : get_config('sitename');
        $customheaders[] = 'Precedence: Bulk';
        // Try to avoid pesky out of office responses
        $messagetext .= "\n\n" . get_string('pleasedonotreplytothismessage') . "\n";
        if ($messagehtml) {
            $messagehtml .= "\n\n<p>" . get_string('pleasedonotreplytothismessage') . "</p>\n";
        }
    } else {
        if (empty($mail->Sender)) {
            $mail->Sender = $userfrom->email;
        }
        $mail->From = $userfrom->email;
        $mail->FromName = display_name($userfrom, $userto);
    }
    $replytoset = false;
    if (!empty($customheaders) && is_array($customheaders)) {
        foreach ($customheaders as $customheader) {
            $mail->AddCustomHeader($customheader);
            if (0 === stripos($customheader, 'reply-to')) {
                $replytoset = true;
            }
        }
    }
    if (!$replytoset) {
        $mail->AddReplyTo($mail->From, $mail->FromName);
    }
    $mail->Subject = substr(stripslashes($subject), 0, 900);
    if ($to = get_config('sendallemailto')) {
        // Admins can configure the system to send all email to a given address
        // instead of whoever would receive it, useful for debugging.
        $mail->addAddress($to);
        $notice = get_string('debugemail', 'mahara', display_name($userto, $userto), $userto->email);
        $messagetext = $notice . "\n\n" . $messagetext;
        if ($messagehtml) {
            $messagehtml = '<p>' . hsc($notice) . '</p>' . $messagehtml;
        }
        $usertoname = display_name($userto, $userto, true) . ' (' . get_string('divertingemailto', 'mahara', $to) . ')';
    } else {
        $usertoname = display_name($userto, $userto);
        if (empty($userto->email)) {
            throw new EmailException("Cannot send email to {$usertoname} with subject {$subject}.  User has no primary email address set.");
        }
        $mail->AddAddress($userto->email, $usertoname);
        $to = $userto->email;
    }
    $mail->WordWrap = 79;
    if ($messagehtml) {
        $mail->IsHTML(true);
        $mail->Encoding = 'quoted-printable';
        $mail->Body = $messagehtml;
        $mail->AltBody = $messagetext;
    } else {
        $mail->IsHTML(false);
        $mail->Body = $messagetext;
    }
    if ($mail->Send()) {
        if ($logfile = get_config('emaillog')) {
            $docroot = get_config('docroot');
            @($client = (string) $_SERVER['REMOTE_ADDR']);
            @($script = (string) $_SERVER['SCRIPT_FILENAME']);
            if (strpos($script, $docroot) === 0) {
                $script = substr($script, strlen($docroot));
            }
            $line = "{$to} <- {$mail->From} - " . str_shorten_text($mail->Subject, 200);
            @error_log('[' . date("Y-m-d h:i:s") . "] [{$client}] [{$script}] {$line}\n", 3, $logfile);
        }
        // Update the count of sent mail
        update_send_count($userto);
        return true;
    }
    throw new EmailException("Couldn't send email to {$usertoname} with subject {$subject}. " . "Error from phpmailer was: " . $mail->ErrorInfo);
}
Example #26
0
 /**
  * Send Recommendation
  *
  * Send an email if the input is valid. Otherwise
  * Show some error messages and the form again
  */
 function _sendRecomm()
 {
     global $_ARRAYLANG, $_CONFIG, $_LANGID, $_CORELANG;
     if (empty($_POST['receivername'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_RECEIVER_NAME'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     }
     if (empty($_POST['receivermail'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_RECEIVER_MAIL'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     } elseif (!$this->isEmail($_POST['receivermail'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_RECEIVER_MAIL'] . ' ' . $_ARRAYLANG['TXT_IS_INVALID'] . '<br />';
     }
     if (empty($_POST['sendername'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_SENDER_NAME'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     }
     if (empty($_POST['sendermail'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_SENDER_MAIL'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     } elseif (!$this->isEmail($_POST['sendermail'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_SENDER_MAIL'] . ' ' . $_ARRAYLANG['TXT_IS_INVALID'] . '<br />';
     }
     if (empty($_POST['comment'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_COMMENT'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     }
     $receivername = $_POST['receivername'];
     $receivermail = $_POST['receivermail'];
     $sendername = $_POST['sendername'];
     $sendermail = $_POST['sendermail'];
     $comment = $_POST['comment'];
     if (!empty($this->_pageMessage) || !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
         //something's missing or wrong
         $this->_objTpl->setVariable('RECOM_STATUS', '<div class="text-danger">' . $this->_pageMessage . '</div>');
         $this->_objTpl->setCurrentBlock('recommend_form');
         $this->_objTpl->setVariable(array('RECOM_SCRIPT' => $this->getJs(), 'RECOM_RECEIVER_NAME' => stripslashes($receivername), 'RECOM_RECEIVER_MAIL' => stripslashes($receivermail), 'RECOM_SENDER_NAME' => stripslashes($sendername), 'RECOM_SENDER_MAIL' => stripslashes($sendermail), 'RECOM_COMMENT' => stripslashes($comment), 'RECOM_PREVIEW' => $this->getMessageBody($_LANGID), 'RECOM_FEMALE_SALUTATION_TEXT' => $this->getFemaleSalutation($_LANGID), 'RECOM_MALE_SALUTATION_TEXT' => $this->getMaleSalutation($_LANGID)));
         $this->_objTpl->setVariable(array('RECOM_TXT_RECEIVER_NAME' => $_ARRAYLANG['TXT_RECEIVERNAME_FRONTEND'], 'RECOM_TXT_RECEIVER_MAIL' => $_ARRAYLANG['TXT_RECEIVERMAIL_FRONTEND'], 'RECOM_TXT_GENDER' => $_ARRAYLANG['TXT_GENDER_FRONTEND'], 'RECOM_TXT_SENDER_NAME' => $_ARRAYLANG['TXT_SENDERNAME_FRONTEND'], 'RECOM_TXT_SENDER_MAIL' => $_ARRAYLANG['TXT_SENDERMAIL_FRONTEND'], 'RECOM_TXT_COMMENT' => $_ARRAYLANG['TXT_COMMENT_FRONTEND'], 'RECOM_TXT_PREVIEW' => $_ARRAYLANG['TXT_PREVIEW_FRONTEND'], 'RECOM_TXT_FEMALE' => $_ARRAYLANG['TXT_FEMALE_FRONTEND'], 'RECOM_TXT_MALE' => $_ARRAYLANG['TXT_MALE_FRONTEND'], 'RECOM_TEXT' => $_ARRAYLANG['TXT_INTRODUCTION'], 'TXT_RECOMMEND_SEND' => $_ARRAYLANG['TXT_RECOMMEND_SEND'], 'TXT_RECOMMEND_DELETE' => $_ARRAYLANG['TXT_RECOMMEND_DELETE']));
         $this->_objTpl->setVariable(array('RECOM_TXT_CAPTCHA' => $_CORELANG['TXT_CORE_CAPTCHA'], 'RECOM_CAPTCHA_CODE' => \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode()));
         if ($this->_objTpl->blockExists('recommend_captcha')) {
             $this->_objTpl->parse('recommend_captcha');
         } else {
             $this->_objTpl->hideBlock('recommend_captcha');
         }
         $this->_objTpl->parseCurrentBlock('recommend_form');
         $this->_objTpl->parse();
     } else {
         //data is valid
         if (empty($_POST['uri'])) {
             $url = ASCMS_PROTOCOL . '://' . $_SERVER['HTTP_HOST'] . ASCMS_PATH_OFFSET;
         } else {
             $url = $_POST['uri'];
         }
         if ($_POST['gender'] == 'male') {
             $salutation = $this->getMaleSalutation($_LANGID);
         } else {
             $salutation = $this->getFemaleSalutation($_LANGID);
         }
         $body = $this->getMessageBody($_LANGID);
         $body = preg_replace('/<SENDER_NAME>/', $sendername, $body);
         $body = preg_replace('/<SENDER_MAIL>/', $sendermail, $body);
         $body = preg_replace('/<RECEIVER_NAME>/', $receivername, $body);
         $body = preg_replace('/<RECEIVER_MAIL>/', $receivermail, $body);
         $body = preg_replace('/<URL>/', $url, $body);
         $body = preg_replace('/<COMMENT>/', $comment, $body);
         $body = preg_replace('/<SALUTATION>/', $salutation, $body);
         $subject = $this->getMessageSubject($_LANGID);
         $subject = preg_replace('/<SENDER_NAME>/', $sendername, $subject);
         $subject = preg_replace('/<SENDER_MAIL>/', $sendermail, $subject);
         $subject = preg_replace('/<RECEIVER_NAME>/', $receivername, $subject);
         $subject = preg_replace('/<RECEIVER_MAIL>/', $receivermail, $subject);
         $subject = preg_replace('/<URL>/', $url, $subject);
         $subject = preg_replace('/<COMMENT>/', $comment, $subject);
         $subject = preg_replace('/<SALUTATION>/', $salutation, $subject);
         if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
             $objMail = new \phpmailer();
             if ($_CONFIG['coreSmtpServer'] > 0) {
                 if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                     $objMail->IsSMTP();
                     $objMail->Host = $arrSmtp['hostname'];
                     $objMail->Port = $arrSmtp['port'];
                     $objMail->SMTPAuth = true;
                     $objMail->Username = $arrSmtp['username'];
                     $objMail->Password = $arrSmtp['password'];
                 }
             }
             $objMail->CharSet = CONTREXX_CHARSET;
             $objMail->SetFrom($sendermail, $sendername);
             $objMail->Subject = $subject;
             $objMail->IsHTML(false);
             $objMail->Body = $body;
             $objMail->AddAddress($receivermail);
             $objMail->Send();
             $objMail->ClearAddresses();
             $objMail->AddAddress($_CONFIG['contactFormEmail']);
             $objMail->Send();
         }
         $this->_objTpl->setVariable('RECOM_STATUS', $_ARRAYLANG['TXT_SENT_OK']);
         $this->_objTpl->parse();
     }
 }
Example #27
0
 /**
  * Validates the submitted comment data and writes it to the databse if valid.
  * Additionally, a notification is send out to the administration about the comment
  * by e-mail (only if the corresponding configuration option is set to do so). 
  *
  * @param   integer News message ID for which the comment shall be stored
  * @param   string  Title of the news message for which the comment shall be stored.
  *                  The title will be used in the notification e-mail
  * @param   string  The poster's name of the comment
  * @param   string  The comment's title
  * @param   string  The comment's message text
  * @global    ADONewConnection
  * @global    array
  * @global    array
  * @global    array
  * @return  array   Returns an array of two elements. The first is either TRUE on success or FALSE on failure.
  *                  The second element contains an error message on failure.  
  */
 private function storeMessageComment($newsMessageId, $newsMessageTitle, $name, $title, $message)
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG;
     if (!isset($_SESSION['news'])) {
         $_SESSION['news'] = array();
         $_SESSION['news']['comments'] = array();
     }
     // just comment
     if ($this->checkForCommentFlooding($newsMessageId)) {
         return array(false, sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_INTERVAL_MSG'], $this->arrSettings['news_comments_timeout']));
     }
     if (empty($title)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_TITLE']);
     }
     if (empty($message)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_MESSAGE']);
     }
     $date = time();
     $userId = 0;
     if (\FWUser::getFWUserObject()->objUser->login()) {
         $userId = \FWUser::getFWUserObject()->objUser->getId();
         $name = \FWUser::getParsedUserTitle($userId);
     } elseif ($this->arrSettings['news_comments_anonymous'] == '1') {
         // deny comment if the poster did not specify his name
         if (empty($name)) {
             return array(false, $_ARRAYLANG['TXT_NEWS_POSTER_NAME_MISSING']);
         }
         // check CAPTCHA for anonymous posters
         if (!\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
             return array(false, null);
         }
     } else {
         // Anonymous comments are not allowed
         return array(false, null);
     }
     $isActive = $this->arrSettings['news_comments_autoactivate'];
     $ipAddress = contrexx_input2raw($_SERVER['REMOTE_ADDR']);
     $objResult = $objDatabase->Execute("\n            INSERT INTO `" . DBPREFIX . "module_news_comments` \n                    SET `title` = '" . contrexx_raw2db($title) . "',\n                        `text` = '" . contrexx_raw2db($message) . "',\n                        `newsid` = '" . contrexx_raw2db($newsMessageId) . "',\n                        `date` = '" . contrexx_raw2db($date) . "',\n                        `poster_name` = '" . contrexx_raw2db($name) . "',\n                        `userid` = '" . contrexx_raw2db($userId) . "',\n                        `ip_address` = '" . contrexx_raw2db($ipAddress) . "',\n                        `is_active` = '" . contrexx_raw2db($isActive) . "'");
     if (!$objResult) {
         return array(false, $_ARRAYLANG['TXT_NEWS_COMMENT_SAVE_ERROR']);
     }
     /* Prevent comment flooding from same user:
        Either user is authenticated or had to validate a CAPTCHA.
        In either way, a Contrexx session had been initialized,
        therefore we are able to use the $_SESSION to log this comment */
     $_SESSION['news']['comments'][$newsMessageId] = $date;
     // Don't send a notification e-mail to the administrator
     if (!$this->arrSettings['news_comments_notification']) {
         return array(true, null);
     }
     // Send a notification e-mail to administrator
     if (!@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         \DBG::msg('Unable to send e-mail notification to admin');
         //DBG::stack();
         return array(true, null);
     }
     $objMail = new \phpmailer();
     if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
             $objMail->IsSMTP();
             $objMail->Host = $arrSmtp['hostname'];
             $objMail->Port = $arrSmtp['port'];
             $objMail->SMTPAuth = true;
             $objMail->Username = $arrSmtp['username'];
             $objMail->Password = $arrSmtp['password'];
         }
     }
     $objMail->CharSet = CONTREXX_CHARSET;
     $objMail->From = $_CONFIG['coreAdminEmail'];
     $objMail->FromName = $_CONFIG['coreGlobalPageTitle'];
     $objMail->IsHTML(false);
     $objMail->Subject = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_SUBJECT'], $newsMessageTitle);
     $manageCommentsUrl = ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? NULL : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_ADMIN_WEB_PATH . '/index.php?cmd=News&act=comments&newsId=' . $newsMessageId;
     $activateCommentTxt = $this->arrSettings['news_comments_autoactivate'] ? '' : sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_LINK'], $manageCommentsUrl);
     $objMail->Body = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_BODY'], $_CONFIG['domainUrl'], $newsMessageTitle, \FWUser::getParsedUserTitle($userId, $name), $title, nl2br($message), $activateCommentTxt);
     $objMail->AddAddress($_CONFIG['coreAdminEmail']);
     if (!$objMail->Send()) {
         \DBG::msg('Sending of notification e-mail failed');
         //DBG::stack();
     }
     return array(true, null);
 }
Example #28
0
function send_email($to, $subject, $body, $from = '', $fromname = '', $stmp = true, $sender = '', $host = '', $port = '', $ssl = '', $username = '', $password = '')
{
    global $charset;
    $mail = new phpmailer();
    if (!$stmp) {
        $mail->IsMail();
    } else {
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        $mail->Host = $host;
        if ($ssl) {
            $mail->SMTPSecure = "ssl";
        }
        if ($port != '') {
            $mail->Port = $port;
        }
        $mail->Username = $username;
        $mail->Password = $password;
    }
    $mail->IsHTML(true);
    $mail->Sender = $sender;
    $mail->FromEmail = $from;
    $mail->FromName = $fromname;
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->CharSet = $charset;
    $mail->WordWrap = 50;
    if (is_array($to)) {
        foreach ($to as $email) {
            $mail->AddAddress($email, "");
        }
    } else {
        $mail->AddAddress($to, "");
    }
    if ($fromname != '') {
        $mail->AddReplyTo($from, $fromname);
    }
    $mail->IsHTML(true);
    if (!$mail->Send()) {
        return "Mailer Error: " . $mail->ErrorInfo;
    } else {
        return true;
    }
}
Example #29
0
 /**
  * Set up and send an email from the shop.
  * @static
  * @param   string    $mailTo           Recipient mail address
  * @param   string    $mailFrom         Sender mail address
  * @param   string    $mailSender       Sender name
  * @param   string    $mailSubject      Message subject
  * @param   string    $mailBody         Message body
  * @return  boolean                     True if the mail could be sent,
  *                                      false otherwise
  * @author  Reto Kohli <*****@*****.**>
  */
 static function send($mailTo, $mailFrom, $mailSender, $mailSubject, $mailBody)
 {
     global $_CONFIG;
     if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         $objMail = new phpmailer();
         if (isset($_CONFIG['coreSmtpServer']) && $_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $from = preg_replace('/\\015\\012/', '', $mailFrom);
         $fromName = preg_replace('/\\015\\012/', '', $mailSender);
         $objMail->SetFrom($from, $fromName);
         $objMail->Subject = $mailSubject;
         $objMail->IsHTML(false);
         $objMail->Body = preg_replace('/\\015\\012/', "\n", $mailBody);
         $objMail->AddAddress($mailTo);
         if ($objMail->Send()) {
             return true;
         }
     }
     return false;
 }
 function envia_clave($configuracion, $email, $email_ins, $user, $clave)
 {
     include_once $configuracion["raiz_documento"] . $configuracion["clases"] . "/mail/class.phpmailer.php";
     include_once $configuracion["raiz_documento"] . $configuracion["clases"] . "/mail/class.smtp.php";
     $mail = new phpmailer();
     $mail->From = "*****@*****.**";
     $mail->FromName = "Banco de Proveedores Universidad Distrital Francisco Jose de Caldas";
     $mail->Host = "mail.udistrital.edu.co";
     $mail->Mailer = "smtp";
     $mail->SMTPAuth = true;
     $mail->Username = "******";
     $mail->Password = "******";
     $mail->Timeout = 120;
     $mail->Charset = "utf-8";
     $mail->IsHTML(false);
     $fecha = date("d-M-Y  h:i:s A");
     $comen = "Mensaje generado automaticamente por el servidor de la Oficina Asesora de Sistemas.\n";
     $comen .= "Este es su usuario y clave para ingresar al Banco de proveedores de la Universidad Distrital.\n\n";
     $sujeto = "Datos de Acceso";
     $cuerpo = "Fecha de envio: " . $fecha . "\n\n";
     $cuerpo .= "Bienvenido al banco de proveedores de la Universidad Distrital Francisco Jose de Caldas \n\n";
     $cuerpo .= "Sus datos de acceso son los siguientes:\n\n";
     $cuerpo .= "Usuario:        " . $user . "\n";
     $cuerpo .= "Clave Acceso:   " . $clave . "\n";
     $cuerpo .= $comen . "\n\n";
     $mail->Body = $cuerpo;
     $mail->Subject = $sujeto;
     $mail->AddAddress($email);
     //$mail->AddCC($email_ins);
     if (!$mail->Send()) {
         $mensaje = "Los datos se intentaron enviar al correo electronico: <b>{$email}</b> pero el envio no fue exitoso<br/>";
     } else {
         $mensaje = "Estos datos fueron enviados al correo electronico: <b>{$email}</b><br/>";
     }
     $mail->ClearAllRecipients();
     return $mensaje;
 }