Archived Forum Post

Index of archived forum posts

Question:

Mailman uses incorrect envelope from ?

Jul 10 '15 at 10:04

Intro

I'm trying to send a large mail to many addressees. I want to get my bounce processing correct, so I'm using VERP: For every addressee, I generate a different sender. It seems however, that Chilkat gets the Envelope-From address incorrect.

Example code

using System;
using Chilkat;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var mailman = new MailMan {SmtpHost = "localhost"};

            mailman.UnlockComponent("Valid key");

            var email = new Email
            {
                Body = "Hello, world!",
                Subject = "Testing 1..2..3..."
            };

            email.AddTo("Me", "recipient1@domain");
            email.FromAddress = "sender1@domain";
            mailman.SendEmail(email);
            Console.WriteLine(mailman.LastErrorText);

            email.ClearTo();
            email.AddTo("Me", "recipient2@domain");
            email.FromAddress = "sender2@domain";
            mailman.SendEmail(email);
            Console.WriteLine(mailman.LastErrorText);
        }
    }
}

Log of lastErrorText

ChilkatLog:
  SendEmail:
    DllDate: Jun 23 2015
    ChilkatVersion: 9.5.0.51
    UnlockPrefix: FLEETLMAILQ
    Username: 976KG12:dijkzeulk
    Architecture: Little Endian; 64-bit
    Language: .NET 4.5 / x64
    VerboseLogging: 0
    sendEmailInner:
      renderToMime:
        createEmailForSending:
          xSigningAlg: sha1
          Auto-generating Message-ID
        --createEmailForSending
        renderToMime: Elapsed time: 0 millisec
      --renderToMime
      sendMimeInner:
        progressTotal: 590
        ensureSmtpSession:
          ensureSmtpConnection:
            SmtpHost: localhost
            SmtpPort: 25
            SmtpUsername: 
            SmtpSsl: 0
            StartTLS: 0
            smtpConnect:
              smtpHostname: localhost
              smtpPort: 25
              connectionIsReady:
                Need new SMTP connection
              --connectionIsReady
              smtpSocketConnect:
                socketOptions:
                  SO_SNDBUF: 262144
                  SO_RCVBUF: 4194304
                  TCP_NODELAY: 1
                  SO_KEEPALIVE: 1
                --socketOptions
              --smtpSocketConnect
              smtpGreeting:
                readSmtpResponse:
                  SmtpCmdResp: 220 976kg12.officedomain ESMTP
                --readSmtpResponse
              --smtpGreeting
              ehloCommand:
                sendCmdToSmtp:
                  SmtpCmdSent: EHLO 976KG12<CRLF>
                --sendCmdToSmtp
                readSmtpResponse:
                  SmtpCmdResp: 250-976kg12.officedomain
                  SmtpCmdResp: 250-SIZE 20480000
                  SmtpCmdResp: 250 AUTH LOGIN
                --readSmtpResponse
              --ehloCommand
            --smtpConnect
          --ensureSmtpConnection
          ensureSmtpAuthenticated:
            smtpAuthenticate:
              No SMTP login provided.
              No SMTP password or OAuth2 access token provided.
              Skipping SMTP authentication because no login/password provided.
              smtp_host: localhost
              smtp_port: 25
              smtp_user: NULL
              auth-method: NONE
              smtpAuthMethod: NONE
              smtpAuthenticate:
                login_method: NONE or already authenticated
              --smtpAuthenticate
              ConnectionType: Unencrypted TCP/IP
            --smtpAuthenticate
          --ensureSmtpAuthenticated
        --ensureSmtpSession
        sendSmtpEmail:
          sendNonPipelining:
            sendMailFrom:
              mailFrom: sender1@domain
              sendCmdToSmtp:
                SmtpCmdSent: MAIL FROM:<sender1@domain><CRLF>
              --sendCmdToSmtp
            --sendMailFrom
            readSmtpResponse:
              SmtpCmdResp: 250 OK
            --readSmtpResponse
            rcptTo:
              sendRcptTo:
                sendCmdToSmtp:
                  SmtpCmdSent: RCPT TO:<recipient1@domain><CRLF>
                --sendCmdToSmtp
              --sendRcptTo
              readRcptTo:
                readSmtpResponse:
                  SmtpCmdResp: 250 OK
                --readSmtpResponse
                recipient: recipient1@domain
              --readRcptTo
            --rcptTo
            sendCmdToSmtp:
              SmtpCmdSent: DATA<CRLF>
            --sendCmdToSmtp
            readSmtpResponse:
              SmtpCmdResp: 354 OK, send.
            --readSmtpResponse
          --sendNonPipelining
          mimeDataSize: 330
          sendDataToSmtp:
            numBytesSent: 330
          --sendDataToSmtp
          sendCmdToSmtp:
            SmtpCmdSent: <CRLF>.<CRLF>
          --sendCmdToSmtp
          readSmtpResponse:
            SmtpCmdResp: 250 Queued (0.000 seconds)
          --readSmtpResponse
        --sendSmtpEmail
      --sendMimeInner
    --sendEmailInner
    Success.
  --SendEmail
--ChilkatLog

ChilkatLog:
  SendEmail:
    DllDate: Jun 23 2015
    ChilkatVersion: 9.5.0.51
    UnlockPrefix: FLEETLMAILQ
    Username: 976KG12:dijkzeulk
    Architecture: Little Endian; 64-bit
    Language: .NET 4.5 / x64
    VerboseLogging: 0
    sendEmailInner:
      renderToMime:
        createEmailForSending:
          xSigningAlg: sha1
          Auto-generating Message-ID
        --createEmailForSending
        renderToMime: Elapsed time: 0 millisec
      --renderToMime
      sendMimeInner:
        progressTotal: 592
        ensureSmtpSession:
          ensureSmtpConnection:
            SmtpHost: localhost
            SmtpPort: 25
            SmtpUsername: 
            SmtpSsl: 0
            StartTLS: 0
            smtpConnect:
              smtpHostname: localhost
              smtpPort: 25
              connectionIsReady:
                Using existing/open SMTP connection to send email.
              --connectionIsReady
              ConnectionType: Unencrypted TCP/IP
            --smtpConnect
          --ensureSmtpConnection
        --ensureSmtpSession
        sendSmtpEmail:
          sendNonPipelining:
            sendMailFrom:
              mailFrom: sender1@domain
              sendCmdToSmtp:
                SmtpCmdSent: MAIL FROM:<sender1@domain><CRLF>
              --sendCmdToSmtp
            --sendMailFrom
            readSmtpResponse:
              SmtpCmdResp: 250 OK
            --readSmtpResponse
            rcptTo:
              sendRcptTo:
                sendCmdToSmtp:
                  SmtpCmdSent: RCPT TO:<recipient2@domain><CRLF>
                --sendCmdToSmtp
              --sendRcptTo
              readRcptTo:
                readSmtpResponse:
                  SmtpCmdResp: 250 OK
                --readSmtpResponse
                recipient: recipient2@domain
              --readRcptTo
            --rcptTo
            sendCmdToSmtp:
              SmtpCmdSent: DATA<CRLF>
            --sendCmdToSmtp
            readSmtpResponse:
              SmtpCmdResp: 354 OK, send.
            --readSmtpResponse
          --sendNonPipelining
          mimeDataSize: 332
          sendDataToSmtp:
            numBytesSent: 332
          --sendDataToSmtp
          sendCmdToSmtp:
            SmtpCmdSent: <CRLF>.<CRLF>
          --sendCmdToSmtp
          readSmtpResponse:
            SmtpCmdResp: 250 Queued (0.000 seconds)
          --readSmtpResponse
        --sendSmtpEmail
      --sendMimeInner
    --sendEmailInner
    Success.
  --SendEmail
--ChilkatLog

Trace of network traffic

220 976kg12.officedomain ESMTP
EHLO 976KG12
250-976kg12.officedomain
250-SIZE 20480000
250 AUTH LOGIN
MAIL FROM:<sender1@domain>
250 OK
RCPT TO:<recipient1@domain>
250 OK
DATA
354 OK, send.
MIME-Version: 1.0
Date: Fri, 10 Jul 2015 14:00:57 +0200
Message-ID: <95EF55139D80C63C1185B280C354B3A0F6F82107@976KG12>
Content-Type: text/plain; format=flowed
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
Subject: Testing 1..2..3...
To: Me <recipient1@domain>
From: sender1@domain

Hello, world!
.
250 Queued (0.000 seconds)
MAIL FROM:<sender1@domain>
250 OK
RCPT TO:<recipient2@domain>
250 OK
DATA
354 OK, send.
MIME-Version: 1.0
Date: Fri, 10 Jul 2015 14:00:57 +0200
Message-ID: <4C01022B58AD46069EB9B3D01E546056D7DC3066@976KG12>
Content-Type: text/plain; format=flowed
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
Subject: Testing 1..2..3...
From: sender2@domain
To: Me <recipient2@domain>

Hello, world!
.
250 Queued (0.000 seconds)
QUIT
221 goodbye

Problem statement

As you can see from the network trace (and the LastErrorText), the MAIL FROM: line lists the address of sender1@somedomain for both e-mails, even though the From: header in the message itself is correct.

Analysis

The problem seems to be caused by me using the same Email object for both e-mails. Creating separate Email objects, or even cloning the current one before setting the FromAddress seems to work around the problem. However, due to the number of recipients, I'm reluctant to go that way, because of the performance penalty involved, both in terms of cpu time and memory usage. Besides, I feel the usage above should "just work" :-)

Any tips/suggestions?

Version numbers

Test has been done with Chilkat 9.5.0.51, Visual Studio 2012


Accepted Answer

This new build fixes it:

32-bit Download: http://www.chilkatsoft.com/download/preRelease/ChilkatDotNet45-9.5.0-win32.zip

64-bit Download: http://www.chilkatsoft.com/download/preRelease/ChilkatDotNet45-9.5.0-x64.zip