How To Edit Scottro’s Reports Mod v5.0 to add custom
From address when emailing a report in 3 easy steps
So you’ve installed scottro’s Reports Mod 5.0 in your OSTicket implementation and noticed that when you email a report to someone the From: tag is populated with his email address. This is of course not the behavior you want from the mod so you want to change it. Then this is the mod to the mod for you!
There are two ways to change this behavior, you can go into the /scp/report_includes/emailReport.php and change the address manually in the source, or you can follow these simple instructions to implement the changes and have it be stored in the database.
Note: for the faint of heart, these and several other small changes that I have emailed scottro should be implemented in the next release [probably 5.1] shortly.
STEP 1
Update your ost_reports table to add the custom email FROM for emailing reports.
ALTER TABLE ost_reports ADD email VARCHAR(255) NOT NULL DEFAULT 'scottro@netins.com';
STEP 2
edit /scp/reports_admin.php
at line 27 add the following:
$email = $_POST['email'];
at line 29 replace
$update="UPDATE ".REPORTS_TABLE." SET 3d=$threeD,graphWidth=$graphWidth,graphHeight= $graphHeight,resolution='$resolution',viewable='$viewable' WHERE 1";
with
$update="UPDATE ".REPORTS_TABLE." SET 3d=$threeD,graphWidth=$graphWidth,graphHeight= $graphHeight,resolution='$resolution',viewable='$viewable',email='$email' WHERE 1";
at line 35 replace
$query = "SELECT 3d,graphWidth,graphHeight,resolution,viewable from ".REPORTS_TABLE." LIMIT 1";
with
$query = "SELECT 3d,graphWidth,graphHeight,resolution,viewable,email from ".REPORTS_TABLE." LIMIT 1";
at line 64 add the following:
<tr> <th>Email From:</th><td><input type="text" name="email" value="<?=$row['email']?>"/></td> </tr>
STEP 3
edit /scp/reports_includes/emailReport.php
replace
$headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n"; $headers .= 'From: osTicket Reports <scottro@netins.com>';
with
// query ost_reports for email From address $query = "SELECT email FROM ".REPORTS_TABLE." LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $email = $row['email']; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n"; $headers .= 'From: osTicket Reports <'.$email.'>';