Пример #1
0
         $arr_header[] = "Bcc: {$var_cc}";
     }
     //$Headers.="MIME-Version: 1.0\n";
     //$Headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
     //$mailstatus=@mail($var_email,$var_subject,$var_body,$Headers);
     $mime = new MIME_mail($row["vDeptMail"], $var_email, $var_subject, $var_body, $arr_header);
     //$mime->fattach($fname, "Resume of $name", $type);
     //							   echo "<br>varuploadfiles(3)==".$var_uploaded_files;
     if ($var_uploaded_files != "") {
         $vAttacharr = explode("|", $var_uploaded_files);
         foreach ($vAttacharr as $key => $value) {
             $split_name_url = explode("*", $value);
             $mime->fattach("../attachments/" . $split_name_url[0], "Attached here is " . $split_name_url[1]);
         }
     }
     $mime->send_mail();
 }
 //insert into reply table
 $sql = "insert into sptbl_replies(nReplyId,nTicketId,nStaffId,vStaffLogin,";
 $sql .= " dDate,tReply,tPvtMessage,vReplyTime,vMachineIP) values('','" . mysql_real_escape_string($var_tid) . "',";
 $sql .= "'" . mysql_real_escape_string($_SESSION["sess_staffid"]) . "',";
 $sql .= "'" . mysql_real_escape_string($_SESSION["sess_staffname"]) . "',now(),'" . mysql_real_escape_string($var_replymatter) . "','" . mysql_real_escape_string($var_pvtmessage) . "',";
 $sql .= "'" . mysql_real_escape_string($var_timespent) . "','" . mysql_real_escape_string(getClientIP()) . "')";
 executeQuery($sql, $conn);
 $var_insert_id = mysql_insert_id($conn);
 //Insert the actionlog
 if (logActivity()) {
     $sql = "Insert into sptbl_actionlog(nALId,nStaffId,vAction,vArea,nRespId,dDate) Values('','" . $_SESSION["sess_staffid"] . "','" . TEXT_ADDITION . "','Reply','" . mysql_real_escape_string($var_insert_id) . "',now())";
     executeQuery($sql, $conn);
 }
 //save attachment
Пример #2
0
/**
 *
 * @author Paul Heaney
 * @todo TODO document this
*/
function saction_MailPreviousMonthsTransactions()
{
    global $CONFIG;
    /*
         Get todays date
         Subtract one from the month and find last month
         Find the last day of last month
         fope(transactions.php?mode=csv&start=X&end=Y&breakdonw=yes
         mail to people
     TODO need a mechanism to subscribe to scheduled events? Could this be done with a trigger? Hmmhhhhhh
    */
    $currentmonth = date('m');
    $currentyear = date('y');
    if ($currentmonth == 1) {
        $currentyear--;
        $lastmonth = 12;
    } else {
        $lastmonth = $currentmonth - 1;
    }
    $startdate = "{$currentyear}-{$lastmonth}-01";
    // Find last date of previous month, 5 day an arbitary choice
    $lastday = date('t', strtotime('{$currentyear}-{$lastmonth}-05'));
    $enddate = "{$currentyear}-{$lastmonth}-{$lastday}";
    $csv = transactions_report('', $startdate, $enddate, '', 'csv', TRUE);
    $extra_headers = "Reply-To: {$CONFIG['support_email']}\nErrors-To: {$CONFIG['support_email']}\n";
    // TODO should probably be different
    $extra_headers .= "X-Mailer: {$CONFIG['application_shortname']} {$application_version_string}/PHP " . phpversion() . "\n";
    $extra_headers .= "X-Originating-IP: {$_SERVER['REMOTE_ADDR']}\n";
    //    if ($ccfield != '')  $extra_headers .= "cc: $ccfield\n";
    //    if ($bccfield != '') $extra_headers .= "Bcc: $bccfield\n";
    $extra_headers .= "\n";
    // add an extra crlf to create a null line to separate headers from body
    // this appears to be required by some email clients - INL
    $subject = sprintf($GLOBALS['strBillableIncidentsForPeriodXtoX'], $startdate, $enddate);
    $bodytext = $GLOBALS['strAttachedIsBillableIncidentsForAbovePeriod'];
    $mime = new MIME_mail($CONFIG['support_email'], $CONFIG['billing_reports_email'], html_entity_decode($subject), $bodytext, $extra_headers, '');
    $mime->attach($csv, "Billable report", OCTET, BASE64, "filename=billable_incidents_{$lastmonth}_{$currentyear}.csv");
    return $mime->send_mail();
}
Пример #3
0
/**
    Send a template email without using a trigger
    @author Ivan Lucas
    @param int $templateid: The ID number of the template to use
    @param array $paramarray. An associative array of template parameters
                 This should at the very least be
                 array('incidentid' => $id, 'triggeruserid' => $sit[2])
    @param string $attach. Path and filename of file to attach
    @param string $attachtype. Type of file to attach (Default 'OCTET')
    @param string $attachdesc. Description of the attachment, (Default, same as filename)
    @retval bool TRUE: The email was sent successfully
    @retval bool FALSE: There was an error sending the mail
    @note This is v2 of this function, it has different paramters than v1
**/
function send_email_template($templateid, $paramarray, $attach = '', $attachtype = '', $attachdesc = '')
{
    global $CONFIG, $application_version_string, $sit;
    if (!is_array($paramarray)) {
        trigger_error("Invalid Parameter Array", E_USER_NOTICE);
        $paramarray = array('triggeruserid' => $sit[2]);
    }
    if (!is_numeric($templateid)) {
        trigger_error("Invalid Template ID '{$templateid}'", E_USER_NOTICE);
    }
    // Grab the template
    $tsql = "SELECT * FROM `{$dbEmailTemplates}` WHERE id={$templateid} LIMIT 1";
    $tresult = mysql_query($tsql);
    if (mysql_error()) {
        trigger_error(mysql_error(), E_USER_WARNING);
    }
    if (mysql_num_rows($tresult) > 0) {
        $template = mysql_fetch_object($tresult);
    }
    $paramarray = array('incidentid' => $paramarray['incidentid'], 'triggeruserid' => $sit[2]);
    $from = replace_specials($template->fromfield, $paramarray);
    $replyto = replace_specials($template->replytofield, $paramarray);
    $ccemail = replace_specials($template->ccfield, $paramarray);
    $bccemail = replace_specials($template->bccfield, $paramarray);
    $toemail = replace_specials($template->tofield, $paramarray);
    $subject = replace_specials($template->subjectfield, $paramarray);
    $body = replace_specials($template->body, $paramarray);
    $extra_headers = "Reply-To: {$replyto}\nErrors-To: " . user_email($sit[2]) . "\n";
    $extra_headers .= "X-Mailer: {$CONFIG['application_shortname']} {$application_version_string}/PHP " . phpversion() . "\n";
    $extra_headers .= "X-Originating-IP: {$_SERVER['REMOTE_ADDR']}\n";
    if ($ccemail != '') {
        $extra_headers .= "CC: {$ccemail}\n";
    }
    if ($bccemail != '') {
        $extra_headers .= "BCC: {$bccemail}\n";
    }
    $extra_headers .= "\n";
    // add an extra crlf to create a null line to separate headers from body
    // this appears to be required by some email clients - INL
    // Removed $mailerror as MIME_mail expects 5 args and not 6 of which is it not expect errors
    $mime = new MIME_mail($from, $toemail, html_entity_decode($subject), '', $extra_headers);
    $mime->attach($body, '', "text-plain; charset={$GLOBALS['i18ncharset']}", 'quoted-printable');
    if (!empty($attach)) {
        if (empty($attachdesc)) {
            $attachdesc = "Attachment named {$attach}";
        }
        $disp = "attachment; filename=\"{$attach}\"; name=\"{$attach}\";";
        $mime->fattach($attach, $attachdesc, $attachtype, 'base64', $disp);
    }
    // actually send the email
    $rtnvalue = $mime->send_mail();
    return $rtnvalue;
}
Пример #4
0
     }
     $disp = "attachment; filename=\"{$name}\"; name=\"{$name}\";";
     $mime->fattach($filename, "Attachment for incident {$id}", $type, 'base64', $disp);
 }
 // Lookup the email template (we need this to find out if the update should be visible or not)
 $sql = "SELECT * FROM `{$dbEmailTemplates}` WHERE id='{$emailtype}' ";
 $result = mysql_query($sql);
 if (mysql_error()) {
     trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
 }
 if (mysql_num_rows($result) < 1) {
     trigger_error("Email template '{$meailtype}' not found", E_USER_WARNING);
 }
 $emailtype = mysql_fetch_object($result);
 // actually send the email
 $mailok = $mime->send_mail();
 if ($mailok == FALSE) {
     trigger_error("Internal error sending email: send_mail() failed", E_USER_WARNING);
 }
 if ($mailok == TRUE) {
     // update incident status if necessary
     switch ($timetonextaction_none) {
         case 'none':
             $timeofnextaction = 0;
             break;
         case 'time':
             $timeofnextaction = calculate_time_of_next_action($timetonextaction_days, $timetonextaction_hours, $timetonextaction_minutes);
             break;
         case 'date':
             // kh: parse date from calendar picker, format: 200-12-31
             $date = explode("-", $date);