Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-31813

email_to_user should allow multiple attachments

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Inactive
    • Icon: Minor Minor
    • None
    • 2.1, 2.2.1
    • Libraries
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • Hide

      The workaround is to use {{

      {get_mailer}

      }} and to customize the mailer behavior for emailing Moodle users.

      Show
      The workaround is to use {{ {get_mailer} }} and to customize the mailer behavior for emailing Moodle users.

      The email_to_user function does not accept multiple attachments, even though the base class PHPMailer supports such behavior with multiple calls to $mailer->AddAttachment.

      My suggestion is to make the 6th and 7th argument to email_to_user accept array values with their string content. Such a solution would be backward compatible with the existing behavior, and support the desired behavior. Here's an example of what some client code would look like:

      $attachments = array();
      foreach ($file in $files) {
        $attachment[$file->get_filename()] = $file->get_filepath();
      }
       
      $filenames = array_keys($attachments);
      $filepaths = array_values($attachments);
       
      email_to_user($user, $USER, 'Multiple attachments', '', '', $filenames, $filepaths);

      I've attached a patch that allows for this behavior (I think).

            Unassigned Unassigned
            pcali1 Philip Cali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.