I’m setting up another install of osTickets for another department (that needs a whole other server). In the process it was requested that they be able to change who the response address is incase they need to send it along to someone else or in order to include multiple addresses. The following is a simple MOD I came up with that seems to work as desired. As always please let me know if you have any questions or notice any problems.
This has been implemented with 1.6RC and 1.6ST and both are functional with the exact same code.
Note: This is for use with sending mail via the PHP mail function and is not intended or coded for use with SMTP sending.
include/class.ticket.php
Inside the postResponse function, just before the $sql variable add the following:
$send_to = $_POST['send_to']; $cc_to = $_POST['cc_to']; $bcc_to = $_POST['bcc_to']; $SENT = "To: $send_to\nCC: $cc_to\nBCC: $bcc_to\n\n"; $response = "$SENT$response";
Now find the following (still inside postResponse):
$body = str_replace('%response',$response,$body);
And below that line add the following line:
$body = str_replace("$SENT",'',$body);
At the bottom of the postResponse function. Find the following code and remove it:
if($email && $email->getId()) { $email->send($this->getEmail(),$subj,$body,$file); }
Now replace it with:
// Just in case they wiped out the send address we still need to make sure it gets somewhere. if($_POST['send_to']){ $email->send($_POST['send_to'],$subj,$body,$file); }else{ $email->send($this->getEmail(),$subj,$body,$file); }
Now we need to setup the actual behind the scenes emailing:
include/class.email.php
Find the following
$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
and just after that add:
// Make sure that tickets is sending via php mail function not smtp or this will not work. $CC = $_POST['cc_to']; $BCC = $_POST['bcc_to'];
Then just a bit further down we need to add to the headers of the email:
$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject, 'Message-ID' =>'<'.Misc::randCode(6).''.time().'-'.$this->getEmail().'>', 'X-Mailer' =>'osTicket v 1.6', 'Content-Type' => 'text/html; charset="UTF-8"' );
For ease of modding just remove all of that and replace it with this:
$headers = array ('From' => $from, 'To' => $to, 'Bcc' => $BCC, 'CC' => $CC, 'Subject' => $subject, 'Message-ID' =>'<'.Misc::randCode(6).''.time().'-'.$this->getEmail().'>', 'X-Mailer' =>'osTicket v 1.6', 'Content-Type' => 'text/html; charset="UTF-8"' );
Ok, thats the functionality behind it all, now we just need to add the ability to use it…
include/staff/viewticket.inc.php
Search for the following:
<input type="hidden" name="a" value="reply">
Now just below that line add the following code:
<table> <tr> <td>To:</td><td><input size=80 type="text" name="send_to" value="<?=$ticket->getEmail()?>"></td> </tr> <tr> <td>CC:</td><td><input size=80 type="text" name="cc_to" ></td> </tr> <tr> <td>BCC:</td><td><input size=80 type="text" name="bcc_to" ></td> </tr> </table>
The following picture shows the “To”, “CC” and “BCC” boxes that allows for changing or adding to the email address to send to. This is automatically filled in with the original email address of the ticket submitter. You can send to multiple email addresses by separating the emails with a comma (bob@example.com, bob2@example.com). Its also user proof… if someone wipes out the email address and doesn’t enter in anything then it will default to the original email address.
Well thats very nice but if we don’t note who we sent it to then we could be getting very confused. Please let us know where we sent what responses to. This note is added to the response database entry but is stripped before emailing the response to the customer.
I have applied to osticket 1.6, it doesn’t work on cc and bcc, it’s only worked on to. please advise.
I am using osticket-1.8.So want to access the code for ‘send reply to alternate/additional email addresses’.Your code doesn’t help me.So please do the needful
Thank you