I'd like to get users more in tune with their data by sending them notifications of certain high-value reports. I really don't want them with the data attached in a PDF or worse, a CSV. I'd rather just have the report link by itself (it already does this).

How can I remove the attachment option altogether?

Perhaps more importantly, how can I modify the email template so I can add some message content directly into the report email itself (not in the PDF attachment). What template is this using? I'd just want to hard-code some text that would apply to all reports.

3 Answers 3


UPDATE: Since 5.29 you can do this in an extension do like the override example at https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterReportVar

In the extension's main file example.php:

function example_civicrm_alterReportVar($varType, &$var, $reportForm) {
  switch ($varType) {
    case 'outputhandlers':
      $var['\CRM_Report_OutputHandler_Pdf'] = '\My\Namespace\PdfOutputHandler';

and then in \My\Namespace\PdfOutputHandler something like:

namespace My\Namespace;
use CRM_Example_ExtensionUtil as E;
class PdfOutputHandler extends \CRM_Report_OutputHandler_Pdf {

  // Override to remove the attachment
  public function getFileName(): string {
    return '';

  // This is similar to the default output but we replace the "file is attached" text. Adjust more as desired.
  // For reference the default is at https://github.com/civicrm/civicrm-core/blob/1f0a905a1a90e3bb68f0492022c488eab1ed3f82/CRM/Report/OutputHandler/Pdf.php#L52-L56
  public function getMailBody(): string {    
    $url = CRM_Utils_System::url('civicrm/report/instance/' . $this->getForm()->getID(), 'reset=1', TRUE);
    return $this->getForm()->getReportHeader() . '<p>' . ts('Report URL') .
      ": {$url}</p>" . '<p>' .
      ts('Here is my text I want to add.') . '</p>' .


The email body content starts here for csv: https://github.com/civicrm/civicrm-core/blob/5.18.4/CRM/Report/Form.php#L3413, and a bit lower down for pdf.

Note also the attachments are hardcoded in, a couple lines lower down.

Note that in the report itself on the Title and Format tab you can add some text/html at the end of the header which will get included in the email.

The code seems to be after hook_civicrm_alterReportVar so I don't think you can use that to remove the attachments, but you should be able to use hook_civicrm_alterMailParams to remove the attachments.


I'd probably just make a separate cron script that emails them the links and whatever text you want, i.e. not using the scheduled report task just a plain cron script. If you want to send to a civi group or something like that then the cron script could be a cv script and then use the civi api inside the script.

  • I need to stick to the civireport email functionality + scheduled job. I have a simple use case and just need to find the template to add text.
    – Andy Burns
    Oct 25, 2019 at 22:36
  • Ok, have added another answer.
    – Demerit
    Oct 25, 2019 at 23:09

We use the 'Title and Format' tab as Demerit mentions above and have stuck some text/html in the 'Report Header' box. To avoid attachments going out with them went with the below parameters for the scheduled job. instanceId=x format=print Not a global solution but may be suitable if results aren't too large.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.