0 votes

We are using the MailBuilder.EnvelopeFrom property in limilabs to set an alternative "envelope from" address while sending emails.

This works partly because in one way or another it looks like there are two "envelope from" statements. It looks like the mail server automatically puts the value of the sender in the "envelope from" field and adds that between brackets.

A second field "Envelope-From" field appears close to the fields : From:, To:, CC: etc..
How can we manipulate the one between brackets?

Received: from [79.143.220.221] (port=53463)
      by panda.hostingpower.nl with esmtpa (Exim 4.95)
      (envelope-from <fromaddress@agilitec.nl>)
      id 1oEBKS-0003CC-ML;
      Wed, 20 Jul 2022 17:16:10 +0200
Message-ID: <3c64fa06-5163-4ba2-8c7a-a59333d2885e@mail.dll>
Subject: [CaseNr=222010033] Testmail
From: <fromaddress@agilitec.nl>
To: <example@agilitec.nl>
Envelope-From: <envelopeFromaddress@agilitec.nl>
by

1 Answer

0 votes
 
Best answer

MailBuilder.EnvelopeFrom sets the email header only. It doesn't change the conversation with SMTP server in any way.

When email is send by Mail.dll, SMTP envelope (SMTP's MAIL FROM command) value is, by default, taken from From/Sender fields.

You can explicitly set the MailBuilder.Sender field (it will also add a "Sender:" header to your message)

-or-

use SmtpMail to set SMTP envelope without adding any header to your email:

IMail email = new MailBuilder().Create();

SmtpMail smtpMail = SmtpMail.CreateFrom(email);
smtpMail.From = "envelopeFromaddress@agilitec.nl";

using (Smtp client = new Smtp())
{
    smtp.Connect("smtp.wiki.net");
    smtp.UseBestLogin("user", "password");

    smtp.SendMessage(smtpMail);

    smtp.Close();
}
by (297k points)
...