zone-eu / zone-mta

📤 Modern outbound MTA cross platform and extendable server application
European Union Public License 1.2
599 stars 96 forks source link

how can change smtp.mailfrom #354

Open Hesammousavi opened 11 months ago

Hesammousavi commented 11 months ago
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@roocket.ir header.s=ml header.b=hl8HLq7F;
       dkim=pass header.i=@mlsend.com header.s=ml header.b=m4zllZXe;
       spf=pass (google.com: domain of bounce-h4v1-1152400@mlsend.com designates 185.249.220.144 as permitted sender) smtp.mailfrom=bounce-h4v1-1152400@mlsend.com;
       dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=roocket.ir
Return-Path: <bounce-h4v1-1152400@mlsend.com>

Hello everyone, I've been extensively exploring the code of the Zone MTA, but I'm having difficulty figuring out how to change the 'smtp.mailfrom' setting. In the provided code snippet, you can see that mlsend.com is sending marketing emails, and the 'smtp.mailfrom' setting is affecting the 'Return-Path.' However, I'd like to set 'smtp.mailfrom' differently while keeping the 'From' envelope as 'info@example.com.' It's important to note that when I create a user with the name 'info@example.com,' the sending email still uses 'info@example.com' as the 'From' address. Could you please provide guidance on how to achieve this within the Zone MTA code?

Hesammousavi commented 10 months ago

@andris9 do you have any solution for this ?

louis-lau commented 10 months ago

I'd like to set 'smtp.mailfrom' differently while keeping the 'From' envelope

Your question is a little confusing to me. Smtp.mailfrom, envelope-from, and return-path are all the exact same thing, aren't they? They all refer to the value of MAIL FROM during the SMTP transaction. You can't set things to a different value if they refer to the same thing.

louis-lau commented 10 months ago

For context, there's a total of 2 from addresses. The one on the message itself, and the one used during the SMTP transaction.

Hesammousavi commented 10 months ago

@louis-lau 1 Screenshot 2023-11-13 081230 Screenshot 2023-11-13 081312

Thank you for your response. I appreciate your attempt to clarify, and I'd like to provide more details to ensure we're on the same page.

In the context of email authentication, specifically DKIM (DomainKeys Identified Mail) and DMARC (Domain-based Message Authentication, Reporting, and Conformance), there are distinctions between 'mailed-by' and 'signed-by' elements.

The screenshot you attached indeed highlights the 'mailed-by' information, indicating the domain responsible for sending the email. However, the 'signed-by' information refers to the domain that has digitally signed the message using DKIM.

In my initial question, I'm specifically interested in changing the 'mailed-by' information in the Return-Path, which is often associated with the 'smtp.mailfrom' or 'envelope-from' address. This can impact how email providers display the sender information to recipients.

For instance, in the provided email header snippet:

plaintext Copy code Return-Path: bounce-h4v1-1152400@mlsend.com The 'mailed-by' or 'envelope-from' domain is 'mlsend.com.' My goal is to configure this 'mailed-by' domain, while still keeping the 'From' address in the email body as 'info@example.com.'

I've noticed that some email marketing platforms, like MailerLite, allow users to customize the 'mailed-by' domain. This customization can contribute to better email deliverability and brand consistency.

If possible, could you guide me on how to achieve this within the Zone MTA code? I'm interested in changing the 'mailed-by' or 'envelope-from' domain without altering the 'From' address in the email body.

I hope this clarifies my inquiry, and I appreciate your assistance in navigating this matter.

Best regards,

louis-lau commented 10 months ago

Sure, so you mean you want to set the envelope from? I think you can just write a plugin that sets envelope.from. The envelope object is available in multiple hooks.

You still seem to be over complicating this. Spf and dkim are checked against the envelope from. So yes, the envelope from domain will be in mailed by and signed by. Otherwise they would not be valid.

Do note that this setup will make your service incompatible with a strict dmarc policy. As with a strict dmarc policy requires the envelope from and the from header domain to be the same. If you use this setup and your customer co figured strict dmarc, all emails will bounce. Just as long as you're aware of that it should be fine.

louis-lau commented 10 months ago

You should probably just make it the same as the from header though, and tell your customers how to set up dkim, spf, dmarc. A strict dkim policy leads to better security for your customers, as it prevents from spoofing of their domain.