Connected IP Address

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
Kelden
Normal user
Normal user
Posts: 46
Joined: 2011-05-02 13:58

Connected IP Address

Post by Kelden » 2021-05-12 00:15

I try to improve this script for signatures
viewtopic.php?t=29348

For this, I need to know the email address the client connects from.
https://www.hmailserver.com/documentati ... ect_client

The Client object only has the IPAddress variable which says:
The TCP/IP address the client is connected to.

That would mean, it's the server address. I don't know why this would be useful, but
I need the client source IP address. How can I get this?

The reason is, I only want to add a signature if the client is our webmail system.
The normal desktop clients all have a signature configured.

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

Re: Connected IP Address

Post by mattg » 2021-05-12 02:28

Kelden wrote:
2021-05-12 00:15
That would mean, it's the server address
Why would it mean that?
(It may at times but that is very rare and dependent on your specific setup)

Have you checked your SMTP logs?
Is connecting IP address recorded there? If so that is the IP that is reported
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: 2694
Joined: 2017-09-12 17:57

Re: Connected IP Address

Post by palinka » 2021-05-12 02:52

Move the code from Sub OnAcceptMessage to a function. Then, in Sub OnAcceptMessage:

if oClient.IPAddress = webmail iP address then
if oMessage.FromAddress contains local domains then
call functionaddsignature
end if
end if

Post Reply