Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 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: 1080 lines (44 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.

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

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.

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
return: \stdClass The current value of the messagedata

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

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
return: \stdClass The current value of the messagedata

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

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
return: string

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

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
return: \stdClass

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

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

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

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

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).

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

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.

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

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.

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

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

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