$var_mail_body = $var_emailheader . "<br>" . TEXT_MAIL_START . "&nbsp;" . htmlentities($var_ulogin) . ",<br>" . ($var_mail_body .= TEXT_MAIL_BODY . ":" . $var_refno . "<br><br>");
     $var_mail_body .= nl2br(htmlentities($var_replymatter)) . "<br>" . $var_emailfooter;
     //$var_subject = TEXT_EMAIL_SUB;
     $var_subject = "Re:" . $row["vTitle"] . "  Id#[" . $row["vRefNo"] . "]";
     $var_body = $var_mail_body;
     //$Headers="From: $var_fromName <$var_fromMail>\n";
     //$Headers.="Reply-To: $var_replyName <$var_replyMail>\n";
     $arr_header = array("Reply-To: " . $row["vDeptMail"]);
     if ($var_cc != "") {
         // $Headers.="Bcc: $var_cc\r\n";
         $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"]) . "',";
Beispiel #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();
}
Beispiel #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;
}
 }
 // send email if no errors
 if ($errors == 0) {
     $extra_headers = "Reply-To: {$replytofield}\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 ($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
     $mime = new MIME_mail($fromfield, $tofield, html_entity_decode($subjectfield), '', $extra_headers, $mailerror);
     // INL 5 Aug 09, quoted-printable seems to split lines in unexpected places, base64 seems to work ok
     $mime->attach($bodytext, 'bodytext', "text/plain; charset={$GLOBALS['i18ncharset']}", 'quoted-printable', 'inline');
     // check for attachment
     //        if ($_FILES['attachment']['name']!='' || strlen($filename) > 3)
     if ($filename != '' && strlen($filename) > 3) {
         //          if (!isset($filename)) $filename = $attachment_fspath.$_FILES['attachment']['name'];   ??? TPG 13/08/2002
         if (!file_exists($filename)) {
             trigger_error("File did not exist upon processing attachment: {$filename}", E_USER_WARNING);
         }
         if ($filename == '') {
             trigger_error("Filename was blank upon processing attachment: {$filename}", E_USER_WARNING);
         }
         // Check file size before sending
         if (filesize($filename) > $CONFIG['upload_max_filesize'] || filesize($filename) == FALSE) {
             trigger_error("User Error: Attachment too large or file upload error, filename: {$filename},  perms: " . fileperms($filename) . ", size:", filesize($filename), E_USER_WARNING);