What is hm_messagereceipients good for?

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
Virinum
Normal user
Normal user
Posts: 69
Joined: 2018-11-23 14:42
Location: Germany

What is hm_messagereceipients good for?

Post by Virinum » 2018-11-26 11:26

Hello!

I recently scrolled through the database of HM and asked myself "What is the table hm_messagereceipients good for?" There are a few entries but I can't see what they do and why they are there.

I would really appreciate it if someone could explain this table to me.

Thanks!

User avatar
jimimaseye
Moderator
Moderator
Posts: 8518
Joined: 2011-09-08 17:48

Re: What is hm_messagereceipients good for?

Post by jimimaseye » 2018-11-26 12:03

The database is designed to hold whatever necessary specific information is required for effective functionality of the software. You can be sure it is in there for a reason. The database itself isn't really there for human eyes and that's why the database structure isn't documented (although there is often a benefit for advanced users to be able to interrogate it for their own reasons.)

To know what each field or column is used for you will need to review the code on github and search for the field and it's inclusion to determine it's use.

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
mattg
Moderator
Moderator
Posts: 20788
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: What is hm_messagereceipients good for?

Post by mattg » 2018-11-27 00:17

messages sent to Distribution lists
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Virinum
Normal user
Normal user
Posts: 69
Joined: 2018-11-23 14:42
Location: Germany

Re: What is hm_messagereceipients good for?

Post by Virinum » 2018-11-27 10:04

Thank you for your answers. But I don't get it.

I know it's not for human eyes but I like to understand why there are entries in this table. I looked into the sourcecode and I found the place where entries are saved to the database. But I just don't understand why these entries get generated.
mattg wrote:
2018-11-27 00:17
messages sent to Distribution lists
Does that mean recipients of messages I sent get stored in this table? Why? And when are they deleted? Becaus in my table there are a few entries. The most filled with my E-Mail-Address in "recipientaddress" and "recipientoriginaladdress". Some with E-Mail-Adresses which don't exist anymore. It seems to me like this table doesn't get cleaned up.

User avatar
RvdH
Senior user
Senior user
Posts: 1042
Joined: 2008-06-27 14:42
Location: Netherlands

Re: What is hm_messagereceipients good for?

Post by RvdH » 2018-11-27 12:35

The message is temporary stored there until the message is delivered to all included recipients, after delivery it should be cleared

https://github.com/hmailserver/hmailser ... ository.cs

Code: Select all

        public async Task<Message> GetMessageToDeliverAsync()
        {
            using (var sqlConnection = new MySqlConnection(_connectionString))
            {
                sqlConnection.Open();

                // TODO: MessageNextTryTime should be included in SQL

                var messages =
                    await sqlConnection.QueryAsync<Message>("SELECT * FROM hm_messages WHERE messagetype = 1 AND messagelocked = 0 LIMIT 1");
                var message = messages.SingleOrDefault();

                if (message != null)
                {
                    var recipients = await sqlConnection.QueryAsync<Recipient>(
                                            "SELECT * FROM hm_messagerecipients where recipientmessageid = @recipientmessageid",
                                                new
                                                {
                                                    recipientmessageid = message.Id
                                                });

                    foreach (var recipient in recipients)
                        message.Recipients.Add(recipient);
                }

                return message;
            }
        }
https://github.com/hmailserver/hmailser ... essage.cpp

Code: Select all

         // If the message is placed into an account, there won't be any recipients
         // connected to it. If the message is still in the queue, we must delete the
         // recipients as well.
         if (pMessage->GetState() != Message::Delivered)
         {
            // Delete recipients.
            SQLCommand deleteCommand("delete from hm_messagerecipients where recipientmessageid = @MESSAGEID");
            deleteCommand.AddParameter("@MESSAGEID", iMessageID);
            
            if (!Application::Instance()->GetDBManager()->Execute(deleteCommand))
            {
               return false;
            }
         }
Take note of the "Auto Increment Value" of the hm_messagerecipients table, this should be a high number
CIDR to RegEx: d-fault.nl/CIDRtoRegEx
DNS Lookup: d-fault.nl/DNSTools
DNSBL Lookup: d-fault.nl/DNSBLLookup
GEOIP Lookup: d-fault.nl/GeoipLookup

Virinum
Normal user
Normal user
Posts: 69
Joined: 2018-11-23 14:42
Location: Germany

Re: What is hm_messagereceipients good for?

Post by Virinum » 2018-11-27 14:55

Ok, I'm beginning to understand.
RvdH wrote:
2018-11-27 12:35

Code: Select all

         // If the message is placed into an account, there won't be any recipients
         // connected to it. If the message is still in the queue, we must delete the
         // recipients as well.
         if (pMessage->GetState() != Message::Delivered)
         {
            // Delete recipients.
            SQLCommand deleteCommand("delete from hm_messagerecipients where recipientmessageid = @MESSAGEID");
            deleteCommand.AddParameter("@MESSAGEID", iMessageID);
            
            if (!Application::Instance()->GetDBManager()->Execute(deleteCommand))
            {
               return false;
            }
         }
So I think this wasn't very successful becaus there are just entries with local account addresses in my hm_messagerecipients table. Also there are no message in the delivery queue. So is it save to delete alle entries of this talbe if there are no pending messages to deliver?

Post Reply