Thread Tools Display Modes
02/20/15, 01:35 PM   #1
Migoda
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 18
Problem with guild mail

Hey fellow coders,

is there any working solution for sending a mass mail to all members of a guild without getting kicked for spam?

In my large trade guild (500 people), we are sending a news mail to our members from time to time. Using the mail function from TIM it stops after ~70 mails and the game kicks for spam.

Can this be avoided? Maybe with setting a delay between each mail?
  Reply With Quote
02/20/15, 05:45 PM   #2
katkat42
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 155
Yes, that would probably work. I think MailR uses a 1-second delay by default.
  Reply With Quote
02/24/15, 12:22 PM   #3
Migoda
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 18
I checked TIMs code and changed the function that processes the mail queue. Here is my solution:

Lua Code:
  1. function tim.sendQueuedMail()
  2.     if tim.mailQueueindex>0 then
  3.         -- EINEN MailQueue-Eintrag senden (pro Aufruf dieser Funktion)
  4.         local mailboxwasopen=tim.MailBoxOpen
  5.         if tim.MailBoxOpen==false then
  6.             RequestOpenMailbox()
  7.         end
  8.         tim.wait4mail=true
  9.         tim.MailInQueue=tim.mailQueue.mTO[tim.mailQueueindex]
  10.         tim.MailInQueueSUB=tim.mailQueue.mSUB[tim.mailQueueindex]
  11.         SendMail(tim.mailQueue.mTO[tim.mailQueueindex], tim.mailQueue.mSUB[tim.mailQueueindex], tim.mailQueue.mTEXT[tim.mailQueueindex])
  12.         if mailboxwasopen==false then
  13.             CloseMailbox()
  14.         end
  15.         tim.mailQueueindex=tim.mailQueueindex-1
  16.     end
  17. end

to

Lua Code:
  1. function tim.sendQueuedMail()
  2.   if tim.mailQueueindex>0 then
  3.       EVENT_MANAGER:RegisterForUpdate("tim_EVENT_EMAIL", tim.throttleTimerMail, function()
  4.         -- EINEN MailQueue-Eintrag senden (pro Aufruf dieser Funktion)
  5.         local mailboxwasopen=tim.MailBoxOpen
  6.         if tim.MailBoxOpen==false then
  7.           RequestOpenMailbox()
  8.         end
  9.         tim.wait4mail=true
  10.         tim.MailInQueue=tim.mailQueue.mTO[tim.mailQueueindex]
  11.         tim.MailInQueueSUB=tim.mailQueue.mSUB[tim.mailQueueindex]
  12.         SendMail(tim.mailQueue.mTO[tim.mailQueueindex], tim.mailQueue.mSUB[tim.mailQueueindex], tim.mailQueue.mTEXT[tim.mailQueueindex])
  13.         if mailboxwasopen==false then
  14.           CloseMailbox()
  15.         end
  16.         tim.mailQueueindex=tim.mailQueueindex-1
  17.         if tim.mailQueueindex==0 then
  18.           EVENT_MANAGER:UnregisterForUpdate("tim_EVENT_EMAIL")
  19.         end
  20.       end)
  21.     end
  22. end

Is that approach with RegisterForUpdate viable or is there a better way to add a simple delay?
  Reply With Quote
02/25/15, 04:25 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,970
I guess it is viable for the current source code as the function tim.sendQueuedMail() is called several times, once for each new guil member mail?

As an alternative you could delay the call to this function tim.sendQueuedMail(), use zo_callLater(tim.sendQueuedMail(), 500) or something like this.

With other addons I have seen sourc code where the EVENTS (crafting_finished e.g.) was the trigger to call the next process.
Maybe there is an event like "MAIL_HAS_BEEN_SENT" and you could use this one to send the next mail (+ delay in between.
  Reply With Quote
02/25/15, 06:03 AM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Baertram View Post
I guess it is viable for the current source code as the function tim.sendQueuedMail() is called several times, once for each new guil member mail?

As an alternative you could delay the call to this function tim.sendQueuedMail(), use zo_callLater(tim.sendQueuedMail(), 500) or something like this.

With other addons I have seen sourc code where the EVENTS (crafting_finished e.g.) was the trigger to call the next process.
Maybe there is an event like "MAIL_HAS_BEEN_SENT" and you could use this one to send the next mail (+ delay in between.
* EVENT_MAIL_SEND_FAILED (*integer* _reason_)
* EVENT_MAIL_SEND_SUCCESS
  Reply With Quote
02/25/15, 02:22 PM   #6
Migoda
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 18
Thanks for your inputs!

After digging a bit deeper in the code i figured out how TIM handles the mailing. tim.sendQueuedMail() is part of the update callback function (fired from OnUpdate), so one mail from the queue is sent every tick.

TIM uses a custom throttle function to control update ticks for special purposes. I ended up using this function in tim.sendQueuedMail() with my desired delay and it works.

Here is the final code:

Lua Code:
  1. function tim.sendQueuedMail()
  2.   if tim.mailQueueindex>0 then
  3.     if (tim.UpdateThrottle("SendQueuedMail", tim.throttleCountMail) == true) then
  4.       -- EINEN MailQueue-Eintrag senden (pro Aufruf dieser Funktion)
  5.       local mailboxwasopen=tim.MailBoxOpen
  6.       if tim.MailBoxOpen==false then
  7.         RequestOpenMailbox()
  8.       end
  9.       tim.wait4mail=true
  10.       tim.MailInQueue=tim.mailQueue.mTO[tim.mailQueueindex]
  11.       tim.MailInQueueSUB=tim.mailQueue.mSUB[tim.mailQueueindex]
  12.       SendMail(tim.mailQueue.mTO[tim.mailQueueindex], tim.mailQueue.mSUB[tim.mailQueueindex], tim.mailQueue.mTEXT[tim.mailQueueindex])
  13.       if mailboxwasopen==false then
  14.         CloseMailbox()
  15.       end
  16.       tim.mailQueueindex=tim.mailQueueindex-1
  17.     end
  18.   end
  19. end
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Problem with guild mail


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off