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).
- duplicates
-
MDL-27081 Adding support for multiple attachments in moodlelib.php/email_to_user
-
- Open
-