Location of forwarding delay setting in source

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
angelas111
New user
New user
Posts: 17
Joined: 2018-02-03 19:06

Location of forwarding delay setting in source

Post by angelas111 » 2018-06-19 23:34

From what I understand after having done extensive reading in this forum, the forwarding of emails popped from external accounts has a delay of 1 minute before they are sent via smtp. I've downloaded the source code and have visual studio 2013. For the life of me I cannot find where to change that setting in the source in order to shorten the time frame. I've looked at header and cpp files for a couple hours today and searched with notepad++. Does anyone know where I can find this? I'm gonna hire a developer to help me edit and compile if this is over my head. But either way I'd like to be able to tell them what file to change. I was able to find the other thing I want to change which is the maximum number of external fetch threads.

Thank you for any help. I greatly appreciate it.

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

Re: Location of forwarding delay setting in source

Post by mattg » 2018-06-20 01:25

If it helps at all , the 1 minute delay is for all forwards, not just forwards from POP3 external download

I'll have a quick look at the code when I get a chance...
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

angelas111
New user
New user
Posts: 17
Joined: 2018-02-03 19:06

Re: Location of forwarding delay setting in source

Post by angelas111 » 2018-06-20 03:55

could it be this?

Code: Select all

E:\dev2\hmailserver-master (1)\hmailserver-master\hmailserver\source\Server\SMTP\SMTPDeliveryManager.cpp (1 hit)
	Line 113:          deliver_messages_.WaitFor(boost::chrono::minutes(1));

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

Re: Location of forwarding delay setting in source

Post by mattg » 2018-06-20 07:05

It could be, but could also be
hmailserver/hmailserver/source/Server/Common/Application/Scheduler.cpp line 42

Perhaps change it to

boost::this_thread::sleep_for(boost::chrono::seconds(10));

and then compile, and see what happens.

Do you have a development machine?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

angelas111
New user
New user
Posts: 17
Joined: 2018-02-03 19:06

Re: Location of forwarding delay setting in source

Post by angelas111 » 2018-06-20 09:50

thank you. yes, i can try it on my main pc as I currently run it on virtual machines.

User avatar
tbrg78_hm
Normal user
Normal user
Posts: 53
Joined: 2013-12-17 19:58
Location: Berlin/Germany

Re: Location of forwarding delay setting in source

Post by tbrg78_hm » 2018-08-08 14:16

I came across this yesterday while investigating the delay occurring when forwarding "alerting" emails to my mobile phone account.

Is there a chance this 1 minute setting will be customizable anyhow?

A setting of 10 seconds would fit the "alerting" background much better. Maybe even have a flag to forward specific mails instantly? o)
If I realize the forwarding via eventhandler script, the delay would occur as well, right? (I use an account rule right now.)

Thank you! o)




.

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

Re: Location of forwarding delay setting in source

Post by mattg » 2018-08-08 14:42

yes eventhandlers also has same issue with forward (but not new mail)

No, this is unlikely to be changed anytime soon
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

palinka
Senior user
Senior user
Posts: 1915
Joined: 2017-09-12 17:57

Re: Location of forwarding delay setting in source

Post by palinka » 2018-08-08 15:05

tbrg78_hm wrote:
2018-08-08 14:16
I came across this yesterday while investigating the delay occurring when forwarding "alerting" emails to my mobile phone account.

Is there a chance this 1 minute setting will be customizable anyhow?

A setting of 10 seconds would fit the "alerting" background much better. Maybe even have a flag to forward specific mails instantly? o)
If I realize the forwarding via eventhandler script, the delay would occur as well, right? (I use an account rule right now.)

Thank you! o)




.
If you just need the alert and not the contents of the message you're forwarding, you can script a notification message to be sent to your cell phone. That should go out immediately.

User avatar
tbrg78_hm
Normal user
Normal user
Posts: 53
Joined: 2013-12-17 19:58
Location: Berlin/Germany

Re: Location of forwarding delay setting in source

Post by tbrg78_hm » 2018-08-08 15:58

@mattg
Ok, thanks! o)

@palinka
You got pm, so we do not interfere here any longer, thank you! o)

User avatar
tbrg78_hm
Normal user
Normal user
Posts: 53
Joined: 2013-12-17 19:58
Location: Berlin/Germany

Re: Location of forwarding delay setting in source

Post by tbrg78_hm » 2018-08-09 17:51

Maybe this helps you, @angelas111, or others:

To get around the 1 minute delay for my "alert" use case, I ditched the forwarding action in the rule and run a custom vbs function instead.
This function creates a copy of the mail to be forwarded and it will be send out immediately. This has a few drawbacks:
- outgoing message is not original anymore
- original headers will be missing e.g. (the API does not seem to allow setting of headers for newly created messages?!)
- probably other things I don't know about (internal routing/rule handling maybe?)

But it obviously has one advantage, it happens instantly, so it's perfect for my "alert" use case, where I also don't care much for headers and things.

To make use if this, you need to:
- add the two functions listed below to your eventhandlers.vbs script file
- set a custom header "X-SendCopyTo" (via rule action) with the to-address (the "forwarding address so to speak)
- run function "CreateAndSendCopyTo" (again, this is a rule action)

Code: Select all

'##############################################################################
Function GetHeaderValueByNameFromMessage(headerName, msgIn)
'##############################################################################
    GetHeaderValueByNameFromMessage = ""
    Dim headerIndex
    For headerIndex = 0 to msgIn.Headers.Count-1
        If headerName = msgIn.Headers(headerIndex).Name Then
            GetHeaderValueByNameFromMessage = msgIn.Headers(headerIndex).Value
            Exit function
        End If 
    Next
End Function

'##############################################################################
'This creates a copy of an email and sends it as new, instead of using the
'built in forwarding features of hmailserver (a rule e.g.), since all forwarded
'mails have a delay of 1 minute (this is an hmailserver internal schedule).
'*** The "to" address is read from "X-SendCopyTo" header. ***
Sub CreateAndSendCopyTo(oMessage)
'##############################################################################
    Dim addressTo : addressTo = GetHeaderValueByNameFromMessage("X-SendCopyTo", oMessage)
    If addressTo = "" Then
        EventLog.Write("CreateAndSendCopyTo() failed, header [X-SendCopyTo] empty/not set.")
        Exit sub
    End if
    
    Dim msgNew : set msgNew = CreateObject("hMailServer.Message") 
    msgNew.From = oMessage.From
    msgNew.FromAddress = oMessage.FromAddress
    msgNew.Subject = oMessage.Subject
    msgNew.AddRecipient "", addressTo
    msgNew.HTMLBody = oMessage.HTMLBody
    msgNew.Save
    
End Sub
Once again, thanks to palinka for giving the simple "send instead of forward" idea! o)

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

Re: Location of forwarding delay setting in source

Post by mattg » 2018-08-09 23:02

tbrg78_hm wrote:
2018-08-09 17:51
- original headers will be missing e.g. (the API does not seem to allow setting of headers for newly created messages?!)
Sure it does

Not tested, but this should copy all headers to the new message
This may have issues, you may need to exclude some, or only copy some

Code: Select all

For i = 0 to oMessage.headers.count -1
   msgNew.Headervalue(oMessage.headers.item(i).name) = oMessage.headers.item(i).value
Next i
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
tbrg78_hm
Normal user
Normal user
Posts: 53
Joined: 2013-12-17 19:58
Location: Berlin/Germany

Re: Location of forwarding delay setting in source

Post by tbrg78_hm » 2018-08-13 14:35

Ok, thank you, that's good! o)
I was searching for an AddHeader() method or something, did not look deeply enough into the properties it seems! o)

Can you think of specific headers which should not be copied into the cloned message, because of.. ? o)

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

Re: Location of forwarding delay setting in source

Post by mattg » 2018-08-13 15:51

Message_ID
User agent
MIME-Version
Content-Type

Previous Spam scoring
All of the 'received' headers
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Post Reply