Show
Copied from MDL-60405
Test Requirements
For these tests you will need:
Outbound mail to be correctly configured and working on your system. Recommend the use of mailhog to catch outbound mail, which may be simpler.
A test email account. This will be the account that your Moodle instance connects to, and as such, this account should have very few emails in its inbox. Scanning the inbox takes time. It must be accessible over imap. outlook and gmail are known to work, however, If using gmail, you may find that IMAP does not work with Google's higher security setting. If IMAP is not working with gmail, check out https://support.google.com/accounts/answer/6010255?hl=en-GB
A second email account, which will be used to send email TO the moodle-controlled account above. You can just use your personal email account here.
Initial setup
Setup VERP handling:
Open Site administration -> Server -> Incoming mail configuration
Enable incoming mail processing;
Add your inbound mailbox details, using the details of the first email account (mailbox name, email domain, incoming mail server, username, password). You can leave SSL on auto detect here. refer to attached screenshot as example
Save changes
Open Site administration -> Server -> Email -> Message Handlers
Enable the "Email to private files" and "Reply to forum posts" handlers
Reduce the max editing time of your forum messages to preserve testing sanity
Open Site administration -> Security -> Site security settings
Set the maxediting time to 1 minute
Create a new course
Enrol a student, s1
Change the email address of the user s1, so that it is set to the address of the second email account
Create a new forum in that course - choose auto subscription
Forum test
As the admin, create a new post in your forum; wait a minute; run cron to send the forum e-mail
Check your e-mail (i.e. check mailhog). You should have received an e-mail for s1.
Next, we'll need to reply to the message as your first user, s1
Copy the reply-to address from the message header.
Compose a new email using the second email account, and paste in the address. Note: This email address must match the address in the user profile as per that step in the initial set up
Set subject to anything
Enter "This is an email reply to the forum post, from s1"
Send the email
Wait a minute, then run cron again. Alternatively, just run the pickup task:
php admin/cli/schedule_task.php --execute=\\tool_messageinbound\\task\\pickup_task
Confirm the blissful absence of error messages in the cron task
Confirm that the message was posted in the forum
Private Files
Log in as s1 and go to the private files page (click the link in the nav drawer)
Confirm that an e-mail address is now shown on the private files page
Send an e-mail, using the second email account, to the address provided in the private files section.
Include two attachments - one inline and one as an attachment
Run cron
Confirm the blissful absence of error messages in the cron task
Confirm that both the files was uploaded to private files