Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Send copy of every email send by OsTicket to cient to a static email address

Dear Forum,

I am using the smtp mail function and would need a copy of every email send by OsTicket being sent to a static email address.

For example lets asume I install osTicket on Then I would simply need a copy of all emails generated throug osTicket to

As this email always stays the same it can be simply copied somewhere in the php code. In my old installation it worked like this, but as I have no idea of php I would need some advise where to add in the new code of osTicket.

Thanks a lot in advance for your help



  • I think that you would want to edit:

    Edit the following functions: send, sendAutoReply, sendAlert on lines 148-165.  Alteranatively it may be easier to simple append the second email address to the $to var.  say on line 147 maybe something like:

    $to .=",";

    I have no idea if this will work... but it might.  And when you upgrade you will have to re-do this change.

    note: the line number may be wrong since you did not provide the version # of osT you are running.

  • Hi Ntozier,

    thanks a lot for your advise. I just tried the change but received the following error message:

     Parse error: syntax error, unexpected T_CONCAT_EQUAL, expecting ')' in /www/htdocs/wxxxxxx/support/include/ on line 148

    In my old osTicket Version the changes are at to places:

     //do some cleanup
            $to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
            $subject=stripslashes(preg_replace("/(\r\n|\r|\n)/s",'', trim($subject)));
            $body = stripslashes(preg_replace("/(\r\n|\r)/s", "\n", trim($message)));
            $from =sprintf('"%s"<%s>',($fromname?$fromname:$this->getEmail()),$this->getEmail());
            $headers = array ('From' => $from,
                              'To' => $to,
                              'Bcc' => "" ,
                              'Subject' => $subject,
                              'Date'=>date('D, d M Y H:i:s O'),
                              'Message-ID' =>'<'.Misc::randCode(6).''.time().'-'.$this->getEmail().'>',
                              'X-Mailer' =>'osTicket v 1.6',
                              'Content-Type' => 'text/html; charset="UTF-8"'
            $mime = new Mail_mime();
            //attachment TODO: allow multiple attachments - $attachment should be mixed parts.
            if($attachment && $attachment['file'] && is_readable($attachment['file'])) { //file of mime type.


      //encode the body
            $body = $mime->get($options);
            //encode the headers.
            $headers = $mime->headers($headers);
            if($smtp){ //Send via SMTP
                $mail = mail::factory('smtp',
                        array ('host' => $smtp['host'],
                               'port' => $smtp['port'],
                               'auth' => $smtp['auth']?true:false,
                               'username' => $smtp['username'],
                               'password' => $smtp['password'],
                               'timeout'  =>20,
                               'debug' => false,
                $result = $mail->send($to, $headers, $body);
                $result = $mail->send('', $headers, $body);
                    return true;

    Unfortunatly I can't find similar code in the new version of osTicket to copy the changes.

    Thanks a lot in advance to everybody for any further advise.

  • Parse error: syntax error, unexpected T_CONCAT_EQUAL, expecting ')' in /www/htdocs/wxxxxxx/support/include/ on line 148

    what do you have on line 148?  It sounds like a ) is missing.
  • Hi,

    I put

     function send($to, $to .=","; $subject, $message, $attachments=null, $options=null) {

    Thanks a lot and best regards
  • Does that actually work?
  • Hi, I tried around a bit and in the end

    function send($to, $subject, $message, $attachments=null, $options=null) {

            $mailer = new Mailer($this);

           return $mailer->send($to .=",", $subject, $message, $options);


    Now the only problem is that the recipient/client also sees in the email header.

    Do you maybe also know a way to put in Bcc so the recipient/client doesn't see it?

    Thanks again for your help :)

  • Try changing

    return $mailer->send($to .=",", $subject, $message, $options);

    return $mailer->send($to .="\\n", $subject, $message, $options);
    You may have to find where the email headers are generated and add the bcc there.  (which btw might be the ones in class.mail.php on line 108 - 115 but I'm not positive about that.
  • Hey Ntozier,

    thanks a lot for your help. Just did the changes and now I receive a copy at

    Unfortunately now in the copy at in the "to" field it puts "client@client.comBcc:mail" and doesn´t receive the email.

    Already tried testing around with adding spaces to the code but it didn't worked out.

    Can you maybe see where is the problem here?

    Thanks again.
  • try \r\n instead of \n.

    Otherwise I think that you will need to put it in the headers.
  • Thanks a lot for your help. Just tried it but unfortunately it stays the same.

    I am sorry I don't understand: What do you mean with "put in the headers"?

    class.mailer.php is already modified around line 108 with

    $headers = array (
                'From' => $this->getFromAddress(),
                'To' => $to,
                'Bcc' => "" ,
                'Subject' => $subject,
                'Date'=> date('D, d M Y H:i:s O'),
                'Message-ID' => $messageId,
                'X-Mailer' =>'osTicket Mailer',
  • That's what I meant.

    Maybe there are more than one place that headers are generated.  You could try searching the project on github

Sign In or Register to comment.