Email forwarding with Exim (Cpanel) and SES (Amazon Simple Email Service)

109 Views Asked by At

By default, SES requires the sender's email to be verified and this is not working with email forwarding. i.e. I receive an email from '[email protected]' and it's forwarded to '[email protected]' this won't work because of the mentioned reason as '[email protected]' is not verified with SES.

I'm trying to update the headers before sending emails so that they are sent from my verified emails on my domain, not users' emails.

Exim advanced editor in Section: TRANSPORTSTART:

ses_forwarded_smtp:
 driver = smtp
 port = 587
 hosts_require_auth = *
 hosts_require_tls = *
 headers_remove = From:Sender:Return-Path:Return-path:DKIM-Signature:Reply- To:Envelope-From:Received:X-Authenticated-Sender
 headers_add = Envelope-From: $local_part@$domain
 headers_add = X-Authenticated-Sender: $local_part@$domain
 headers_add = Reply-To: $sender_address
 headers_add = X-Original-Sender-Address: $local_part@$domain
 headers_add = From: $local_part@$domain
 headers_add = Sender: $local_part@$domain
 headers_add = Return-Path: $local_part@$domain
 max_rcpt = 1
 return_path = ${srs_encode {SRS_SECRET} {$local_part@$domain} {$domain}}

this didn't work the headers were not changed so I tried to update custom_begin_pre_recipient:

warn
domains = +local_domains
remove_header = From
remove_header = Sender
remove_header = Return-Path
remove_header = Return-path
remove_header = DKIM-Signature
remove_header = Reply-To
remove_header = Envelope-From
remove_header = X-Envelope-From
remove_header = X-Authenticated-Sender
add_header = Envelope-From: $local_part@$domain
add_header = X-Authenticated-Sender: $local_part@$domain
#add_header = Reply-To: $sender_address
add_header = Reply-To: $local_part@$domain
add_header = X-Original-Sender-Address: $local_part@$domain
add_header = From: $local_part@$domain
add_header = Sender: $local_part@$domain
add_header = Return-Path: $local_part@$domain
add_header = Return-path: $local_part@$domain
add_header = X-Envelope-From: $local_part@$domain
remove_header  = Received

This worked with most of the headers but not all and SES still detects the sender ad '[email protected]'.

These are the headers I received:

Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from hostname.mydomain.com
    by hostname.mydomain.com with LMTP
    id P1OrDxKyg8AZjHKjQ
    (envelope-from <[email protected]>)
    for <[email protected]>; Tue, 18 Jul 2023 15:38:58 +0000
Return-path: <[email protected]>
Envelope-to: [email protected]
Delivery-date: Tue, 18 Jul 2023 15:38:58 +0000
Date: Tue, 18 Jul 2023 15:38:08 +0000
To: email <[email protected]>
Subject: Subject
Message-ID: <jHHuxRzdJgmIAD7GBiQrk95_n4qkoVex2oN1WIgCm_Ml_q2YHqLidzw=@example.com>
Feedback-ID: 21140702:user
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_4wAzkOkVR8ZDkTtuq7xT8pYLfUNrQEvrE"
Envelope-From: [email protected]
X-Authenticated-Sender: [email protected]
Reply-To: [email protected]
X-Original-Sender-Address: [email protected]
From: [email protected]
Sender: [email protected]
Return-Path: [email protected]
Return-path: [email protected]
X-Envelope-From: [email protected]
X-Spam-Status: No, score=2.7
X-Spam-Score: 27
X-Spam-Bar: ++
X-Ham-Report: Spam detection software, running on the system "hostname.mydomain.com",
    has NOT identified this incoming email as spam. The original
    message has been attached to this so you can view it or label
    similar future email. If you have any questions, see
    root\@localhost for details.
    Content preview: Sent from mobile
    Content analysis details: (2.7 points, 5.0 required)
    pts rule name description
    ---- ---------------------- --------------------------------------------------
    0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
    mail domains are different
    0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends
    in digit
    [notverified[at]example.com]
    0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
    provider
    [notverfied[at]example.com]
    0.0 HTML_MESSAGE BODY: HTML included in message
    2.0 PYZOR_CHECK Listed in Pyzor
    (https://pyzor.readthedocs.io/en/latest/)
    0.0 KAM_DMARC_STATUS Test Rule for DKIM or SPF Failure with Strict
    Alignment
    -0.0 T_SCC_BODY_TEXT_LINE No description available.
    0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and
    EnvelopeFrom freemail headers are
    different
X-Spam-Flag: NO

I get this error:

SMTP error from remote mail server after end of data: 554 Message rejected: Email address is not verified. The following identities failed the check in region EU-WEST-1: [email protected]

Is it possible to remove this email '[email protected]' from the headers and make it as it's sent from '[email protected]'?

0

There are 0 best solutions below