Sending

Introduction

Empath uses what may at first seem a rather complex system for sending messages. As you look harder, you'll see it's actually deceptively simple, and has two advantages: It is fully asynchronous and completely safe.

Empath's MailSender class is your interface to mail sending. All communication should be done with the base class, not with derived classes such as EmpathMailSenderQmail

The class EmpathMailSender has a simple interface. You can either send or queue a message. These interface methods are also provided via the 'empath' macro.

You can call empath->send(RMM::RMessage) and forget about what happens. You don't need to know what mail sending objects are available and you don't need to worry about what happens to the message. These issues are dealt with by the Empath object and the MailSender base class respectively.

The EmpathMailSender implementation.

There are various possible async operations that can take place. They are all tagged with different names.

Tag Circumstance Success Failure
message->pending An attempt has been made to put a message into the queue. Send the message as soon as ready. Inform the user that the message could not be queued. Tell them where the message has been saved for safekeeping.
message->queue An attempt has been made to put a message into the queue. Do nothing. Inform the user that the message could not be queued. Tell them where the message has been saved for safekeeping.
message->send An attempt has been made to retrieve a message (from the queue) for sending. Send the message as soon as ready. Inform the user that a message that was queued for delivery can now not be retrieved from the queue and that it may have been removed.
queue->sent An attempt has been made to copy a message from the queue to the sent folder. Remove the message from the queue. Inform the user that a message in the queue can not be moved to the sent folder.
queue->remove An attempt has been made to remove a message from the queue. Do nothing. Inform the user that a message in the queue could not be removed.