I have been trying to resolve for a couple of months using multiple different configurations.
The local delivery to a Dovecot mailbox ([email protected]) keeps the original sender ([email protected]) in the FROM address.
The remote delivery using SendGrid SMTP server via a virtual forward to ([email protected]) works if:
in smtp_header_checks if there is
/^From:(.*)$/ REPLACE From: [email protected]
and in main.cf
sender_canonical_classes = envelope_sender
smtp_header_checks = regexp:/etc/postfix/smtp_header_checks
I have tried to add a reply-to to the header so that the receivers, who get the forwarded email, can reply to it.
In smtp_header_checks I put
/^From:(.*)$/ REPLACE Reply-To:$1<br>
/^From:(.*)$/ REPLACE From: [email protected]
but this gives a 550 Error
Feb 14 13:40:03 club-jowett-vm postfix/smtp[12857]: BB2AD65E91: replace: header From: <[email protected]>: From: [email protected] Reply-To: <[email protected]>
Feb 14 13:40:03 t-vm postfix/smtp[12857]: BB2AD65E91: to=<[email protected]>, orig_to=<[email protected]>, relay=smtp.sendgrid.net[54.228.39.88]:587, delay=2.3, delays=1.6/0.19/0.48/0.05, dsn=5.0.0, status=bounced (host smtp.sendgrid.net[54.228.39.88] said: 550 The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements (in reply to end of DATA command))
I have tried other configurations one of which added the reply-to but some receivers rejected the email because of multiple ReplyTo headers.
I have also tried /^From:(.*)$/ PREPEND Reply-To:$1
which gives the same 550 error.
Has anyone a configuration that works, please?