Jump to content

External Mail


Auntie Mangos

Recommended Posts

  • 42 years later...

Working for me now:

void WorldSession::SendExternalMails()
{
   sLog.outDebug("External Mail - Send Mails from Queue...");
   QueryResult* result = CharacterDatabase.Query("SELECT id,receiver,subject,message,money,item,item_count FROM mail_external");
   if (!result)
   {
       sLog.outDebug("External Mail - No Mails in Queue...");
       return;
   }
   else
   {
       do
       {
           Field *fields = result->Fetch();
           uint32 id = fields[0].GetUInt32();
           Player *pReceiver = sObjectMgr.GetPlayer(fields[1].GetUInt64());
           std::string subject = fields[2].GetString();
           std::string message = fields[3].GetString();
           uint32 money = fields[4].GetUInt32();
           uint32 ItemID = fields[5].GetUInt32();
           uint32 ItemCount = fields[6].GetUInt32();

           if (pReceiver)
           {
               MailDraft draft;
               draft.SetSubjectAndBody(subject, message);
               MailSender sender(MAIL_NORMAL, pReceiver ? pReceiver->GetObjectGuid().GetCounter() : 0, MAIL_STATIONERY_GM);
               MailReceiver reciever(pReceiver, pReceiver->GetObjectGuid());

               sLog.outDebug("External Mail - Sending mail to %u, Item:%u", pReceiver->GetObjectGuid().GetCounter(), ItemID);
               uint32 itemTextId = !message.empty() ? sObjectMgr.CreateItemText(message) : 0;
               if (ItemID != 0)
               {
                   Item* ToMailItem = Item::CreateItem(ItemID, ItemCount, pReceiver);
                   if (ToMailItem)
                   {
                       ToMailItem->SaveToDB();
                       draft.AddItem(ToMailItem);
                   }
                   draft.SetMoney(money);
               }
               else
                   draft.SetMoney(money);

               draft.SendMailTo(reciever,sender,MAIL_CHECK_MASK_RETURNED);
               CharacterDatabase.PExecute("DELETE FROM mail_external WHERE id=%u", id);
           }
           else
               sLog.outDebug("External Mail - Mail with unknown player GUID %u in mail_external",fields[1].GetUInt32());
       }
       while(result->NextRow());
   }
   sLog.outDebug("External Mail - All Mails Sent...");
}

        static Player* GetPlayer(uint64 guid)
       {
           ObjectGuid oGuid;
           oGuid.Set(guid);
           return GetPlayer(oGuid);
       }

Link to comment
Share on other sites

RA had its limitations to be used as an app to external mail, since u could use just one connection at time

but since SOAP was introduced there is no need for it, something external just would make server read an unnecessary extra table and add extra unnecessary code to server

and as easy to make an web page to deal with soap as to run a simple sql command u just need to add another class and call it with arguments basically same way it used to be done with RA if i remember it right

Link to comment
Share on other sites

RA had its limitations to be used as an app to external mail, since u could use just one connection at time

but since SOAP was introduced there is no need for it, something external just would make server read an unnecessary extra table and add extra unnecessary code to server

and as easy to make an web page to deal with soap as to run a simple sql command u just need to add another class and call it with arguments basically same way it used to be done with RA if i remember it right

Well personally i like that you do not have to have mangosd online to insert mails in the queue. That is why ^^,

Link to comment
Share on other sites

In order to send ingame mails / items created via PHP Interfaces, we had used external mail system in my old project group, too.

However, since SOAP is implemented you should be able to write kind of litte PHP webservices daemon, which tries to connect to mangosd's SOAP server and executes a mail queue step by step, as long the connection to the SOAP server is established.

Link to comment
Share on other sites

Thank you for updating the mail patch, LilleCarl! :D

I've never bothered with an Apache server and all the MaNGOS administrator web scripts, since it's just me tinkering around in my private world. That mail patch is perfect for my needs and I've missed having it.

We need to keep utilities like this alive. There are still many like me, who do not used web-based tools for their server.

Link to comment
Share on other sites

Of course you should use whatever fits best for you and your purposes. :)

I just want to point out that no Apache or other web server is required. You can (and should) run such a script through the php interpreter on the command line.

You can also use other techniques and languages, to provide a "real" external mail system. (C / C + + / C # / Perl / Phython, blahblahblah)

Link to comment
Share on other sites

Being the Swiss Army knife that it is, I'm not surprised there's a PHP interpreter bundled with Linux. Windows is another matter. That's why I use the mail patch.

Since all I really need is a simple way to mail items to my various toons and bots, it's the best fit for my Win server, but that may change as I transition to Linux in the near future.

I do like the idea of a more complete mail server and would strongly encourage you to polish and expand your work, Sys. Many of the cross-platform utilities have become outdated and their developers have long since abandoned them. It would be great to have a new generation of such devs offering up their fresh ideas to make server admin a little more convenient and flexible.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use