Page 1 of 1

Change sender

Posted: 2020-12-18 21:53
by fibzocker
Hi, I have the following problem
I have installed and configured the mail server, receiving emails works fine.
But I would also like to send emails while I ran into the problem that a dyndns is blocked by googel and co.
However, I have had the experience when I have the sender of the email sent via another service e.g. web.de will accept this so I set up a relay smtp in the email server.
The relay smtp server recognizes that the domain that sends the email is not the email with which I connected the smtp server. So I would like to intercept my email in Hmailserver and replace it with a different header. I've been looking for a solution for a long time but haven't found anything suitable yet.
Perhaps does any of you have an idea how to do that best?

Re: Change sender

Posted: 2020-12-18 22:21
by palinka
Add this to the bottom of your program files\hmailserver\bin\hmailserver.ini and restart hmailserver.

Code: Select all

[settings]
RewriteEnvelopeFromWhenForwarding=1
; Defaults to 0 or disabled.
; This will rewrite the FROM envelope of an email message when forwarding it on to another address.
; The default is to retain the original FROM address (potentially causing SPF checking failures by the forward address server).

Re: Change sender

Posted: 2020-12-18 23:07
by fibzocker
Thank you for your quick answer. I added the characters in my .ini and restarted the server. Unfortunately, this did not help. I still get the return email when I send it.

Remote server replied: 553 5.7.1 <my@domain.de>: Sender address rejected: not owned by user xyz@web.de.

Re: Change sender

Posted: 2020-12-18 23:42
by mikedibella
That error generally means you are trying to submit email for delivery to an address that is external to that service (i.e. submitting an email to user1@google.com for delivery to user2@yahoo.com) using authentication (i.e. authenticating as the username associated with mailbox user1@google.com) and the from fields (i.e. MAIL FROM: envelope and and From: header) doesn't match the authenticated identity.

If that is the type of relay service you have, you will only be able to relay mail using the service if the from identity in the message matches the login identity's email address.

Re: Change sender

Posted: 2020-12-18 23:49
by fibzocker
Yes, I have already noticed that, but how can I create a rule for this and adjust the sender address?
(I'm new to the topic)

Re: Change sender

Posted: 2020-12-19 01:01
by mikedibella
Keep RewriteEnvelopeFromWhenForwarding=1 in hMailServer.ini and create a Rule with Actions to Set headers.

Set the originator headers to the mailbox owner. See https://tools.ietf.org/html/rfc5322#section-3.6.2.

Re: Change sender

Posted: 2020-12-19 14:10
by fibzocker
I kept the command in the .ini file and created a rule that reads:
criteria: use AND Field = From Comparison = Contains Value = my locale email
actions: action = set header value Headername = the email from smtp provider

Re: Change sender

Posted: 2020-12-19 14:10
by fibzocker
unfortunately I get the same email from relay smtp server again

what am I doing wrong ?

Re: Change sender

Posted: 2020-12-19 20:02
by mikedibella
Try:

Set From: to xyz@web.de
Set Sender: to my@domain.de
Set Reply-to: to my@domain.de
Set Return-path: to my@domain.de

Re: Change sender

Posted: 2020-12-19 20:18
by fibzocker
I'm sorry, but I can't find where to enter this. Maybe with Rules Criteria but you can only adjust from or to?

Re: Change sender

Posted: 2020-12-19 22:16
by mikedibella
Rule
Actions
Set header value

Don't include ":", just name, ie. From for From: header

Re: Change sender

Posted: 2020-12-19 22:25
by fibzocker
I have now configured it that way. But it still doesn't work.

Pictures:

https://ibb.co/nmxRyZH
https://ibb.co/dbGmrYv

Re: Change sender

Posted: 2020-12-19 22:35
by mikedibella
Four Actions

Header name Value

From xyz@web.de
Sender my@domain.de
Reply-to my@domain.de
Return-path my@domain.de

Re: Change sender

Posted: 2020-12-19 22:47
by fibzocker
I followed your instructions and as you can see on picture 1 selected set header value then as you can see in picture 2 I inserted the text parts you said and as you can see in picture 3 made this for everyone but it does not work.

1 https://ibb.co/hHn6Xyx
2 https://ibb.co/wL8zg4x
3 https://ibb.co/yRKgm3S

Re: Change sender

Posted: 2020-12-19 22:52
by mikedibella
Untitled.png
Untitled.png (4.44 KiB) Viewed 4403 times

Re: Change sender

Posted: 2020-12-19 23:05
by fibzocker
I have corrected my header information but the sender is still not recognized as the owner.
Did I set it that way for Criteria or is there something wrong?

Image

Re: Change sender

Posted: 2020-12-20 01:06
by mikedibella
That criteria should fire the Rule Actions for messages from my@domain.de. Is the Rule a Mailbox or Global Rule?

Enable SMTP, Application, and Debug logging. Send a message and post the log for that send.

Re: Change sender

Posted: 2020-12-20 15:31
by fibzocker
This is the log file that is created when sending an email. I found out that it is up to the sender. It has to be the same as the one on the smtp server. What is the easiest way to set this up?

Image

Re: Change sender

Posted: 2020-12-20 18:49
by mikedibella
Can't tell if the rule is firing because you don't have application and debug logging enabled.

I see a missing MAIL FROM: verb on the outbound connection. I've seen that in described in other posts but I don'r remember the cause. Maybe someone else on the board can chime in on that.

Re: Change sender

Posted: 2020-12-20 19:23
by fibzocker
"DEBUG" 672 "2020-12-20 18:17:47.312" "Creating session 8"
"DEBUG" 672 "2020-12-20 18:17:47.312" "TCP connection started for session 1"
"SMTPD" 672 1 "2020-12-20 18:17:47.328" "192.168.2.1" "SENT: 220 MAIL-PC ESMTP"
"SMTPD" 1248 1 "2020-12-20 18:17:47.328" "192.168.2.1" "RECEIVED: EHLO XXXX"
"SMTPD" 1248 1 "2020-12-20 18:17:47.328" "192.168.2.1" "SENT: 250-MAIL-PC[nl]250-SIZE 20480000[nl]250-AUTH LOGIN[nl]250 HELP"
"SMTPD" 1132 1 "2020-12-20 18:17:47.328" "192.168.2.1" "RECEIVED: AUTH LOGIN"
"SMTPD" 1132 1 "2020-12-20 18:17:47.328" "192.168.2.1" "SENT: 334 VXNlcm5hbWU6"
"SMTPD" 672 1 "2020-12-20 18:17:47.328" "192.168.2.1" "RECEIVED: cG9zdEBoZXJyeXNlcnZlci5kZG5zLm5ldA=="
"SMTPD" 672 1 "2020-12-20 18:17:47.343" "192.168.2.1" "SENT: 334 UGFzc3dvcmQ6"
"SMTPD" 672 1 "2020-12-20 18:17:47.343" "192.168.2.1" "RECEIVED: ***"
"SMTPD" 672 1 "2020-12-20 18:17:47.343" "192.168.2.1" "SENT: 235 authenticated."
"SMTPD" 948 1 "2020-12-20 18:17:47.359" "192.168.2.1" "RECEIVED: MAIL FROM: <XXXXXXX>"
"SMTPD" 948 1 "2020-12-20 18:17:47.375" "192.168.2.1" "SENT: 250 OK"
"SMTPD" 672 1 "2020-12-20 18:17:47.375" "192.168.2.1" "RECEIVED: RCPT TO: <XXXXXX>"
"SMTPD" 672 1 "2020-12-20 18:17:47.390" "192.168.2.1" "SENT: 250 OK"
"SMTPD" 1248 1 "2020-12-20 18:17:47.390" "192.168.2.1" "RECEIVED: DATA"
"SMTPD" 1248 1 "2020-12-20 18:17:47.390" "192.168.2.1" "SENT: 354 OK, send."
"DEBUG" 948 "2020-12-20 18:17:47.421" "Adding task AsynchronousTask to work queue Asynchronous task queue"
"DEBUG" 1932 "2020-12-20 18:17:47.421" "Executing task AsynchronousTask in work queue Asynchronous task queue"
"DEBUG" 1932 "2020-12-20 18:17:47.437" "Saving message: {6C5B503D-CE56-4BF9-856A-70F4FD8E3D9D}.eml"
"DEBUG" 1932 "2020-12-20 18:17:47.453" "Requesting SMTPDeliveryManager to start message delivery"
"SMTPD" 1932 1 "2020-12-20 18:17:47.453" "192.168.2.1" "SENT: 250 Queued (0.032 seconds)"
"DEBUG" 1944 "2020-12-20 18:17:47.453" "Adding task DeliveryTask to work queue SMTP delivery queue"
"DEBUG" 1992 "2020-12-20 18:17:47.453" "Executing task DeliveryTask in work queue SMTP delivery queue"
"DEBUG" 1992 "2020-12-20 18:17:47.453" "Delivering message..."
"APPLICATION" 1992 "2020-12-20 18:17:47.453" "SMTPDeliverer - Message 197: Delivering message from XXXXXX to XXXXXX File: C:\Program Files (x86)\hMailServer\Data\{6C5B503D-CE56-4BF9-856A-70F4FD8E3D9D}.eml"
"DEBUG" 1992 "2020-12-20 18:17:47.484" "Applying rules"
"DEBUG" 1992 "2020-12-20 18:17:47.484" "Applying rule test"
"DEBUG" 1992 "2020-12-20 18:17:47.484" "Performing rule action"
"DEBUG" 1992 "2020-12-20 18:17:47.484" "Performing rule action"
"DEBUG" 1992 "2020-12-20 18:17:47.500" "Performing rule action"
"DEBUG" 1992 "2020-12-20 18:17:47.500" "Performing rule action"
"DEBUG" 1992 "2020-12-20 18:17:47.500" "Performing rule action"
"DEBUG" 1992 "2020-12-20 18:17:47.500" "Performing rule action"
"DEBUG" 1992 "2020-12-20 18:17:47.500" "Performing local delivery"
"DEBUG" 1992 "2020-12-20 18:17:47.500" "Local delivery completed"
"APPLICATION" 1992 "2020-12-20 18:17:47.546" "SMTPDeliverer - Message 197: Relaying to host smtp.mail.de."
"DEBUG" 1992 "2020-12-20 18:17:47.546" "Starting external delivery process. Server: smtp.mail.de (62.201.172.21), Port: 25, Security: 3, User name: XXX@mail.de"
"DEBUG" 1992 "2020-12-20 18:17:47.546" "Creating session 9"
"DEBUG" 1132 "2020-12-20 18:17:47.609" "TCP connection started for session 9"
"SMTPC" 1132 9 "2020-12-20 18:17:47.656" "62.201.172.21" "RECEIVED: 220 smtp04.mail.de ESMTP"
"SMTPC" 1132 9 "2020-12-20 18:17:47.656" "62.201.172.21" "SENT: EHLO MAIL-PC"
"SMTPC" 1356 9 "2020-12-20 18:17:47.750" "62.201.172.21" "RECEIVED: 250-smtp04.mail.de[nl]250-PIPELINING[nl]250-SIZE 160000000[nl]250-STARTTLS[nl]250-ENHANCEDSTATUSCODES[nl]250 DSN"
"SMTPC" 1356 9 "2020-12-20 18:17:47.750" "62.201.172.21" "SENT: STARTTLS"
"SMTPC" 1164 9 "2020-12-20 18:17:47.812" "62.201.172.21" "RECEIVED: 220 2.0.0 Ready to start TLS"
"DEBUG" 1164 "2020-12-20 18:17:47.812" "Performing SSL/TLS handshake for session 9. Verify certificate: True, Expected remote host name: smtp.mail.de"
"DEBUG" 952 "2020-12-20 18:17:48.484" "Saving message: {DDDE280B-E2CC-45FA-992A-532E4E2F27AD}.eml"
"DEBUG" 952 "2020-12-20 18:17:48.484" "Reading messages from database."
"DEBUG" 1164 "2020-12-20 18:17:48.500" "Certificate verification succeeded for session 9."
"SMTPC" 952 9 "2020-12-20 18:17:48.625" "62.201.172.21" "SENT: EHLO MAIL-PC"
"SMTPC" 1356 9 "2020-12-20 18:17:48.703" "62.201.172.21" "RECEIVED: 250-smtp04.mail.de[nl]250-PIPELINING[nl]250-SIZE 160000000[nl]250-AUTH PLAIN LOGIN[nl]250-AUTH=PLAIN LOGIN[nl]250-ENHANCEDSTATUSCODES[nl]250 DSN"
"SMTPC" 1356 9 "2020-12-20 18:17:48.703" "62.201.172.21" "SENT: AUTH LOGIN"
"SMTPC" 1356 9 "2020-12-20 18:17:48.828" "62.201.172.21" "RECEIVED: 334 VXNlcm5hbWU6"
"SMTPC" 1356 9 "2020-12-20 18:17:48.828" "62.201.172.21" "SENT: YWxsQG1haWwuZGU="
"SMTPC" 1324 9 "2020-12-20 18:17:48.984" "62.201.172.21" "RECEIVED: 334 UGFzc3dvcmQ6"
"SMTPC" 1324 9 "2020-12-20 18:17:48.984" "62.201.172.21" "SENT: ***"
"SMTPC" 1136 9 "2020-12-20 18:17:49.062" "62.201.172.21" "RECEIVED: 235 2.7.0 Authentication successful"
"SMTPC" 1136 9 "2020-12-20 18:17:49.062" "62.201.172.21" "SENT: ***"
"SMTPC" 1136 9 "2020-12-20 18:17:49.203" "62.201.172.21" "RECEIVED: 250 2.1.0 Ok"
"SMTPC" 1136 9 "2020-12-20 18:17:49.203" "62.201.172.21" "SENT: RCPT TO:<XXXXXX>"
"SMTPC" 1324 9 "2020-12-20 18:17:49.328" "62.201.172.21" "RECEIVED: 553 5.7.1 <XXXXX>: Sender address rejected: not owned by user XXX@mail.de. Bei Fragen schreiben Sie uns gern mit der exakten Fehlermeldung eine E-Mail an support@mail.de"
"SMTPC" 1324 9 "2020-12-20 18:17:49.328" "62.201.172.21" "SENT: QUIT"
"SMTPC" 1324 9 "2020-12-20 18:17:49.406" "62.201.172.21" "RECEIVED: 221 2.0.0 Bye"
"DEBUG" 1324 "2020-12-20 18:17:49.406" "Ending session 9"
"DEBUG" 1992 "2020-12-20 18:17:49.406" "External delivery process completed"
"DEBUG" 1992 "2020-12-20 18:17:49.406" "Summarizing delivery result"
"DEBUG" 1992 "2020-12-20 18:17:49.406" "Summarized delivery results"
"DEBUG" 1992 "2020-12-20 18:17:49.406" "SD::SubmitErrorLog_"
"DEBUG" 1992 "2020-12-20 18:17:49.406" "Saving message: {FE58A738-180E-4D2D-8B4B-0F6F0E07B015}.eml"
"DEBUG" 1992 "2020-12-20 18:17:49.406" "SD::~SubmitErrorLog_"
"DEBUG" 1992 "2020-12-20 18:17:49.406" "Deleting message"
"DEBUG" 1992 "2020-12-20 18:17:49.406" "Deleting message file."
"APPLICATION" 1992 "2020-12-20 18:17:49.406" "SMTPDeliverer - Message 197: Message delivery thread completed."
"SMTPD" 1356 1 "2020-12-20 18:17:49.968" "192.168.2.1" "RECEIVED: QUIT"
"SMTPD" 1356 1 "2020-12-20 18:17:49.968" "192.168.2.1" "SENT: 221 goodbye"
"DEBUG" 1136 "2020-12-20 18:17:49.968" "Ending session 1"


Sorry I forgot to debug. I made all sensitive data unrecognizable with XXX

Re: Change sender

Posted: 2020-12-20 19:53
by mikedibella
You are authenticating using the username all@mail.de. So you have to set the From: header to one of the proxy addresses for that mailbox, presumably the proxy addresses expected is "all@mail.de".

Re: Change sender

Posted: 2020-12-20 20:59
by fibzocker
I have already set the From header to the user Email All@mail.de so it looks for the smtp server as if the Sneder is the email all@mail.de and not my local email address

Re: Change sender

Posted: 2020-12-20 21:21
by mikedibella
Then the problem is that the MAIL FROM: verb is missing in the outbound sequence. You need to send MAIL FROM: all@mail.de before RCPT TO:. I have seen that issue before but I don't recall how it was solved.

Re: Change sender

Posted: 2020-12-20 21:34
by fibzocker
I was looking for something and found another mail server ebi which the sending via the smtp server works with the server there is the simple function to always overwrite the sender when I activate this action the smtp server accepts the sending. Now comes my problem, the server only provides users that I can create that is not enough for me if you want more you have to pay a high license price that I don't want. Do you have any idea how you can send that with the hmailserver?

Re: Change sender

Posted: 2020-12-20 22:58
by fibzocker
I was looking for something through the forum and came across the VBscript which apparently should solve the problem, but now I don't know how to change this so that it also works for my email variant. Do you have an idea?

Sub OnAcceptMessage(oClient, oMessage)
dim addr
addr=Split(Replace(oMessage.From,".loc",".de"),"<")
oMessage.From = "<"+addr(1)
oMessage.FromAddress = "<"+addr(1)
oMessage.Save
End Sub

Re: Change sender

Posted: 2020-12-21 01:44
by mikedibella
Here is the post that described the issue with missing MAIL FROM:

https://www.hmailserver.com/forum/viewt ... OM#p223743

Try removing the Rule Action that rewrites Return-path.

Then retest and post the updated log.

Re: Change sender

Posted: 2021-01-21 18:44
by berg128
To me it looks like your trying to authenticate against the gateway server you are trying to sent to. You will probably have to disable that so that you are an anonymous user/server who is trying to deliver to a known address on the receiving server side.