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 www.mydomain.org. Then I would simply need a copy of all emails generated throug osTicket to copy@mydomain.org.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 copy@mydomain.org in the new code of osTicket.Thanks a lot in advance for your helpStefan

I think that you would want to edit:/include/class.email.phpEdit 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 .=",copy@mydomain.org";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/class.email.php on line 148In my old osTicket Version the changes are at to places:... //do some cleanup        $eol="\n";        $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)));        $fromname=$this->getName();        $from =sprintf('"%s"<%s>',($fromname?$fromname:$this->getEmail()),$this->getEmail());        $headers = array ('From' => $from,                          'To' => $to,                          'Bcc' => "copy@mydomain.com" ,                          'Subject' => $subject,                          'Date'=>date('D, d M Y H O'),                          'Message-ID' =>'<'.Misc:(6).''.time().'-'.$this->getEmail().'>',                          'X-Mailer' =>'osTicket v 1.6',                          'Content-Type' => 'text/html; charset="UTF-8"'                          );        $mime = new Mail_mime();        $mime->setTXTBody($body);        //attachment TODO: allow multiple attachments - $attachment should be mixed parts.        if($attachment && $attachment && is_readable($attachment)) { //file of mime type.            $mime->addAttachment($attachment,$attachment,$attachment);        }...and...  //encode the body        $body = $mime->get($options);        //encode the headers.        $headers = $mime->headers($headers);        if($smtp){ //Send via SMTP            $mail = mail:('smtp',                    array ('host' => $smtp,                           'port' => $smtp,                           'auth' => $smtp?true,                           'username' => $smtp,                           'password' => $smtp,                           'timeout'  =>20,                           'debug' => false,                           ));            $result = $mail->send($to, $headers, $body);            $result = $mail->send('copy@mydomain.com', $headers, $body);            if(!PEAR:($result))                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/class.email.php on line 148what do you have on line 148?  It sounds like a ) is missing.

Hi,I put function send($to, $to .=",copy@mydomain.org"; $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);        if($attachments)            $mailer->addAttachments($attachments);       return $mailer->send($to .=",copy@mydomain.com", $subject, $message, $options);    }works.Now the only problem is that the recipient/client also sees copy@mydomain.com in the email header. Do you maybe also know a way to put copy@mydomain.com in Bcc so the recipient/client doesn't see it?Thanks again for your help :)

Try changingreturn $mailer->send($to .=",copy@mydomain.com", $subject, $message, $options);toreturn $mailer->send($to .="\nBcc@example.com\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 mail@example.com.Unfortunately now in the copy at mail@example.com in the "to" field it puts "client@client.comBcc"@example.com and client@client.com 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' => "copy@mydomain.com" ,            'Subject' => $subject,            'Date'=> date('D, d M Y H 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

Write a Reply...