Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

The Mail Pickup Manager.

Copyright: 2014 Andrew Nicols
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1061 lines (43 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: manager  - X-Ref

Mail Pickup Manager.

get_imap_client()   X-Ref
Retrieve the connection to the IMAP client.

return: bool Whether a connection was successfully established.

close_connection()   X-Ref
Shutdown and close the connection to the IMAP client.


get_confirmation_folder()   X-Ref
Get the confirmation folder imap name

return: string

get_mailbox()   X-Ref
Get the current mailbox information.

return: \Horde_Imap_Client_Mailbox

pickup_messages()   X-Ref
Execute the main Inbound Message pickup task.

return: bool

process_existing_message(\stdClass $maildata)   X-Ref
Process a message received and validated by the Inbound Message processor.

return: bool Whether the message was successfully processed.
param: \stdClass $maildata The data retrieved from the database for the current record.

tidy_old_messages()   X-Ref
Tidy up old messages in the confirmation folder.

return: bool Whether tidying occurred successfully.

tidy_old_verification_failures()   X-Ref
Remove older verification failures.

return: void

process_message(\Horde_Imap_Client_Data_Fetch $message,$viewreadmessages = false,$skipsenderverification = false)   X-Ref
Process a message and pass it through the Inbound Message handling systems.

param: \Horde_Imap_Client_Data_Fetch $message The message to process
param: bool $viewreadmessages Whether to also look at messages which have been marked as read
param: bool $skipsenderverification Whether to skip the sender verification stage

process_message_data(\Horde_Imap_Client_Data_Envelope $envelope,\Horde_Imap_Client_Data_Fetch $basemessagedata,$messageid)   X-Ref
Process a message to retrieve it's header data without body and attachemnts.

return: \stdClass The current value of the messagedata
param: \Horde_Imap_Client_Data_Envelope $envelope The Envelope of the message
param: \Horde_Imap_Client_Data_Fetch $basemessagedata The structure and part of the message body
param: string|\Horde_Imap_Client_Ids $messageid The Hore message Uid

process_message_data_body(\Horde_Imap_Client_Data_Fetch $basemessagedata,$messageid)   X-Ref
Process a message again to add body and attachment data.

return: \stdClass The current value of the messagedata
param: \Horde_Imap_Client_Data_Fetch $basemessagedata The structure and part of the message body
param: string|\Horde_Imap_Client_Ids $messageid The Hore message Uid

process_message_part_body($messagedata, $partdata, $part)   X-Ref
Process the messagedata and part data to extract the content of this part.

return: string
param: \Horde_Imap_Client_Data_Fetch $messagedata The structure and part of the message body
param: \Horde_Mime_Part $partdata The part data
param: string $part The part ID

process_message_part_attachment($messagedata, $partdata, $part, $filename)   X-Ref
Process a message again to add body and attachment data.

return: \stdClass
param: \Horde_Imap_Client_Data_Fetch $messagedata The structure and part of the message body
param: \Horde_Mime_Part $partdata The part data
param: string $part The part ID.
param: string $filename The filename of the attachment

passes_key_validation($status, $messageid)   X-Ref
Check whether the key provided is valid.

return: bool
param: bool $status
param: mixed $messageid The Hore message Uid

add_flag_to_message($messageid, $flag)   X-Ref
Add the specified flag to the message.

param: mixed $messageid
param: string $flag The flag to add

remove_flag_from_message($messageid, $flag)   X-Ref
Remove the specified flag from the message.

param: mixed $messageid
param: string $flag The flag to remove

message_has_flag($messageid, $flag)   X-Ref
Check whether the message has the specified flag

return: bool
param: mixed $messageid
param: string $flag The flag to check

ensure_mailboxes_exist()   X-Ref
Ensure that all mailboxes exist.


is_bulk_message(\Horde_Imap_Client_Data_Fetch $message,$messageid)   X-Ref
Attempt to determine whether this message is a bulk message (e.g. automated reply).

return: boolean
param: \Horde_Imap_Client_Data_Fetch $message The message to process
param: string|\Horde_Imap_Client_Ids $messageid The Hore message Uid

send_to_handler()   X-Ref
Send the message to the appropriate handler.

return: bool

handle_verification_failure(\Horde_Imap_Client_Ids $messageids,$recipient)   X-Ref
Handle failure of sender verification.

This will send a notification to the user identified in the Inbound Message address informing them that a message has been
stored. The message includes a verification link and reply-to address which is handled by the
invalid_recipient_handler.

return: bool
param: \Horde_Imap_Client_Ids $messageids
param: string $recipient The message recipient

inform_user_of_error($error)   X-Ref
Inform the identified sender of a processing error.

param: string $error The error message

inform_user_of_success(\stdClass $messagedata, $handlerresult)   X-Ref
Inform the identified sender that message processing was successful.

return: bool
param: \stdClass $messagedata The data for the current message being processed.
param: mixed $handlerresult The result returned by the handler.

get_reply_subject($subject)   X-Ref
Return a formatted subject line for replies.

return: string The formatted reply subject
param: string $subject The subject string