change Sender Address
change Sender Address
Hello Guys,
my name is Timur from Germany. I have a problem with hmailserver and would appreciate, if someone could help me. In my Lan i have some smtp clients that dont support smtp auth. thats why i set up an hmailserver with smtp relayer and disables "requires smtp auth" in ip ranges settings.
as far as these smtp clients use the same sender address thats configured in my smtp relayer account everything works fine. lets call this Email address smtprelay@mydomain.com. Unfortunaltely i have some smtp client, that cannot use smtprelay@mydomain.com as the sender address.They have subdomain sender addresses, like server1@sub.mydomain.com. so i decided to replace the sender address by a rule. So i created:
criteria
from|contains|sub.mydomain.com
Actions
Set header value|from|smtprelay@mydomain.com
but its not working
how can i access the modified Email?
in hmailserver_awstats.log its trying to send with server1@sub.mydomain.com
in htmailserver log it says
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Applying rules"
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Applying rule Rewrite sender"
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Performing rule action"
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Performing local delivery"
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Local delivery completed"
"SMTPC" 6828 73 "2019-12-17 05:47:57.958" "83.246.107.173" "RECEIVED: 354 Start mail input; end with <CRLF>.<CRLF>"
"SMTPC" 6828 73 "2019-12-17 05:47:57.958" "83.246.107.173" "SENT: [nl]."
"SMTPC" 4352 73 "2019-12-17 05:47:58.036" "83.246.107.173" "RECEIVED: 550 5.7.60 SMTP; Client does not have permissions to send as this sender"
"SMTPC" 4352 73 "2019-12-17 05:47:58.036" "83.246.107.173" "SENT: QUIT"
"SMTPC" 5296 73 "2019-12-17 05:47:58.067" "83.246.107.173" "RECEIVED: 221 2.0.0 Service closing transmission channel"
thanks for help
Timur
my name is Timur from Germany. I have a problem with hmailserver and would appreciate, if someone could help me. In my Lan i have some smtp clients that dont support smtp auth. thats why i set up an hmailserver with smtp relayer and disables "requires smtp auth" in ip ranges settings.
as far as these smtp clients use the same sender address thats configured in my smtp relayer account everything works fine. lets call this Email address smtprelay@mydomain.com. Unfortunaltely i have some smtp client, that cannot use smtprelay@mydomain.com as the sender address.They have subdomain sender addresses, like server1@sub.mydomain.com. so i decided to replace the sender address by a rule. So i created:
criteria
from|contains|sub.mydomain.com
Actions
Set header value|from|smtprelay@mydomain.com
but its not working
how can i access the modified Email?
in hmailserver_awstats.log its trying to send with server1@sub.mydomain.com
in htmailserver log it says
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Applying rules"
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Applying rule Rewrite sender"
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Performing rule action"
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Performing local delivery"
"DEBUG" 4300 "2019-12-17 05:42:24.381" "Local delivery completed"
"SMTPC" 6828 73 "2019-12-17 05:47:57.958" "83.246.107.173" "RECEIVED: 354 Start mail input; end with <CRLF>.<CRLF>"
"SMTPC" 6828 73 "2019-12-17 05:47:57.958" "83.246.107.173" "SENT: [nl]."
"SMTPC" 4352 73 "2019-12-17 05:47:58.036" "83.246.107.173" "RECEIVED: 550 5.7.60 SMTP; Client does not have permissions to send as this sender"
"SMTPC" 4352 73 "2019-12-17 05:47:58.036" "83.246.107.173" "SENT: QUIT"
"SMTPC" 5296 73 "2019-12-17 05:47:58.067" "83.246.107.173" "RECEIVED: 221 2.0.0 Service closing transmission channel"
thanks for help
Timur
Re: change Sender Address
Here is a script to do that
Add to your eventhandlers.vbs, and enable scripting in the admin gui
From this thread, kudos to @tunis
viewtopic.php?f=9&t=32387#p202248
Code: Select all
Sub OnAcceptMessage(oClient, oMessage)
if instr(oMessage.FromAddress,"sub.domain.com") >0 then
oldFrom = oMessage.FromAddress
oMessage.FromAddress = "new@example.com"
oMessage.From = "<new@example.com>"
EventLog.Write("Testing account From rewrite " & oldFrom & " - to - " & oMessage.FromAddress )
oMessage.save
Result.value = 0
end if
End Sub
From this thread, kudos to @tunis
viewtopic.php?f=9&t=32387#p202248
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
https://www.hmailserver.com/documentation
Re: change Sender Address
it worked like a charm. Thank you so much!!!
Re: change Sender Address
Hello MattG,
can i bother you once more.
is it possible to change the script to make it universal. What i mean is, i have different sender addresses, but they have the same pattern, for example: server1@sub.mydomain.com, server5@sub2.mydomain.com or server2@sub125.mydomain.com
the script should eliminate the part of the subdomain, regardless which value it has. So it should replace it with: server1@mydomain.com, server5@mydomain.com or server2@mydomain.com
Is this possible?
i would appreciate your help
thanks
Timur
can i bother you once more.
is it possible to change the script to make it universal. What i mean is, i have different sender addresses, but they have the same pattern, for example: server1@sub.mydomain.com, server5@sub2.mydomain.com or server2@sub125.mydomain.com
the script should eliminate the part of the subdomain, regardless which value it has. So it should replace it with: server1@mydomain.com, server5@mydomain.com or server2@mydomain.com
Is this possible?
i would appreciate your help
thanks
Timur
Re: change Sender Address
just change this line
if instr(oMessage.FromAddress,"sub.domain.com") >0 then
to be like
if instr(oMessage.FromAddress,".domain.com") >0 then
And maybe even you can remove the leading . to just have "domain.com"
if instr(oMessage.FromAddress,"sub.domain.com") >0 then
to be like
if instr(oMessage.FromAddress,".domain.com") >0 then
And maybe even you can remove the leading . to just have "domain.com"
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
https://www.hmailserver.com/documentation
Re: change Sender Address
ok, but how do i pick the local Part of the Email address?
for example server5@sub2.mydomain.com and put it in
oMessage.From = "<server5@mydomain.com>"
for example server5@sub2.mydomain.com and put it in
oMessage.From = "<server5@mydomain.com>"
Re: change Sender Address
left(oMessage.FromAddress, instr(oMessage.FromAddress, "@")-1)
I think the -1 is needed without testing, but it may not be.
Post your script as it stands if you are still stuck please
I think the -1 is needed without testing, but it may not be.
Post your script as it stands if you are still stuck please
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
https://www.hmailserver.com/documentation
Re: change Sender Address
how can i add mydomain.com ?
this does not work:
oMessage.FromAddress = left(oMessage.FromAddress, instr(oMessage.FromAddress, "@") & "mydomain.com" )
this does not work:
oMessage.FromAddress = left(oMessage.FromAddress, instr(oMessage.FromAddress, "@") & "mydomain.com" )
Re: change Sender Address
Bracket is in the wrong place
oMessage.FromAddress = left(oMessage.FromAddress, instr(oMessage.FromAddress, "@")) & "mydomain.com"
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
https://www.hmailserver.com/documentation
Re: change Sender Address
it worked, thanks
Re: change Sender Address
Posted for anyone who might find this useful: to replace one domain with another. This also updates the Message ID value successfully.
Code: Select all
Sub OnAcceptMessage(oClient, oMessage)
Dim domainOld, domainNew
domainOld = "domain1.com"
domainNew = "domain2.com"
If (instr(oMessage.FromAddress, domainOld) > 0) Then
oldFrom = oMessage.FromAddress
oMessage.FromAddress = Replace(oMessage.FromAddress, domainOld, domainNew)
oMessage.From = Replace(oMessage.From, domainOld, domainNew)
oMessage.HeaderValue("Message-ID") = Replace(oMessage.HeaderValue("Message-ID"), domainOld, domainNew)
'EventLog.Write("Testing account From rewrite " & oldFrom & " - to - " & oMessage.FromAddress & " ID:" & oMessage.HeaderValue("Message-ID") )
oMessage.Save
Result.value = 0
End If
End Sub