The last time I did that I just replaced the class "MailHandler"
All emails are processed by it.

If added a table "mail_queue" with the fields:
subject, body, status, receipients, status, error (all string, receipients
can be a comma separated list of emails)

And then the MailHandler just adds entries to this table with status "new".
And a scheduler checks every xx seconds this table and processes the first
10 entries where status LIKE "new" and sets the status to "processing".
If the Mail sending itself throws and error/exception, this string is
written to "error" and the status is set to "fail".
If the mail sending is "sucess" the record will be deleted from the table.

If the entry is status LIKE "new" => status is new and the mail will be send
If the entry is status LIKE "processing" => the mail is currently in
sending process

So the queue does only process those emails that are status LIKE "new" to
prevent double sending, and by keeping the failed ones we might in the
future be able to show some nice UI dialog in the Admin UI with the error
report (and give the admin an option to delete even those entries after
checking it).

Sebastian


2013/2/16 seba.wag...@gmail.com <seba.wag...@gmail.com>

> Yeah sure just go ahead
> Am 16.02.2013 17:01 schrieb "Maxim Solodovnik" <solomax...@gmail.com>:
>
> Hello All,
>>
>> I'm going to implement MailQ to be able to resend emails in case of any
>> error is occurred.
>>
>> Currently we have following list of emails:
>>
>>    1. Meeting reminder (sent by schedule, periodically)
>>    2. Invitation to the room
>>    3. Appointment creation/modification/cancellation
>>    4. User creation
>>    5. Password reset
>>    6. Feedback
>>    7. Add user to the contact list/accept it
>>
>> I believe all emails from the list above except for 1) should be added to
>> the mail Q instead of being immediately sent and keep sending until success.
>>
>> Do you have any concerns/ideas regarding the topic?
>> I'm going to implement my solution in case there will be no objections :)
>>
>>
>> --
>> WBR
>> Maxim aka solomax
>>
>


-- 
Sebastian Wagner
https://twitter.com/#!/dead_lock
http://www.webbase-design.de
http://www.wagner-sebastian.com
seba.wag...@gmail.com

Reply via email to