Skip to content

[Email] Add attachment functionality#10374

Open
CamilleBeau wants to merge 2 commits intoaces:mainfrom
CamilleBeau:2026_02_18_email_attachments
Open

[Email] Add attachment functionality#10374
CamilleBeau wants to merge 2 commits intoaces:mainfrom
CamilleBeau:2026_02_18_email_attachments

Conversation

@CamilleBeau
Copy link
Collaborator

Brief summary of changes

This PR adds to the Email.class.inc library file to be able to add attachments to emails sent by LORIS.

This is done by detecting whether an array of attachments was added, and if so, changing the Content-Type to multi-part and adding each attachment individually. If no attachments are passed as an argument, then the Email class continues as it did before.

  • Have you updated related documentation?

Testing instructions (if applicable)

  1. Add a 9th argument to an Email::send function somewhere in LORIS with a full filepath passed through
  2. Have the email sent to your own address, and make sure that the attachment is added to the sent email properly
  3. Try sending an email like normal without an attachment, and make sure that that works as usual.

Link(s) to related issue(s)

  • Resolves # (Reference the issue this fixes, if any.)

@github-actions github-actions bot added the Language: PHP PR or issue that update PHP code label Feb 18, 2026
@ridz1208
Copy link
Collaborator

@CamilleBeau FYI here is how I had implemented it. I really don't recall why I did moved away from the Email class but I rememebr trying and giving up at a certain point.

            //email
            $config =& NDB_Config::singleton();
            $from = ($config->getSetting('mail'))['From'];
            
            $email = new PHPMailer();
            $email->SetFrom($from);
            $email->Subject = "THIS IS THE SUBJECT LINE";
            $email->Body = "THIS IS THE BODY";
            $recipientEmail = $config->getSetting("mailto");
            $email->AddAddress($recipientEmail);
            $email->AddAddress("rida.abou-haidar@mcin.ca");
            $email->AddAttachment( $EOS_path , $EOS_file);
            $email->AddAttachment( $o_path , $o_file);
            $email->Send();

@CamilleBeau CamilleBeau requested a review from driusan March 2, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: PHP PR or issue that update PHP code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants