jstedfast / MailKit

A cross-platform .NET library for IMAP, POP3, and SMTP.
http://www.mimekit.net
MIT License
6.04k stars 809 forks source link

SMTP not working with Strato.de #1745

Closed janwiesemann closed 2 months ago

janwiesemann commented 2 months ago

Describe the bug I'm trying to setup a Bitwarden instance. It's relying on MailKit but I've been experiencing some issues. Due to those I've setup a small test environment. It successfully connects to my SMTP server, delivers the SMTP-data but I never receive a mail.

Platform (please complete the following information):

Exception none

To Reproduce Steps to reproduce the behavior:

  1. Try sending a mail using the code from below

Expected behavior Receiving a mail

Code Snippets

using MailKit;
using MailKit.Net.Smtp;
using MimeKit;

namespace ConsoleApp1
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            MimeMessage message = new MimeMessage();
            message.MessageId = $"<{DateTime.Now.Ticks}@janwiesemann.de>";
            message.From.Add(new MailboxAddress("Bitwarden", "noreply@janwiesemann.de"));
            message.To.Add(new MailboxAddress("test", "xxx@janwiesemann.de"));
            message.Subject = "How you doin'?";

            message.Body = new TextPart("plain") { Text = "Bananenbrot" };

            using (SmtpClient client = new SmtpClient(new ProtocolLogger(Console.OpenStandardOutput())))
            {
                client.Connect("smtp.strato.com", 465, true);

                // Note: only needed if the SMTP server requires authentication
                client.Authenticate("noreply@janwiesemann.de", "xxx");

                client.Send(message);
                client.Disconnect(true);
            }
        }
    }
}

Protocol Logs

Connected to smtps://smtp.strato.com:465/
S: 220 smtp.strato.com ESMTP RZmta (P16 -)
C: EHLO janwiesemann.de
S: 250-smtp.strato.com greets 79.252.219.7
S: 250-ENHANCEDSTATUSCODES
S: 250-PIPELINING
S: 250-8BITMIME
S: 250-DELIVERBY
S: 250-SIZE 104857600
S: 250-LIMITS RCPTMAX=1000 MAILMAX=1000
S: 250-AUTH PLAIN LOGIN CRAM-MD5 DIGEST-MD5
S: 250-REQUIRETLS
S: 250 HELP
C: AUTH DIGEST-MD5
S: 334  xxx
C: ********
S: 334 xxx
C:
S: 235 2.7.0 OK Authenticated
C: MAIL FROM:<noreply@janwiesemann.de> SIZE=267 REQUIRETLS
C: RCPT TO:<xxx@janwiesemann.de>
S: 250 2.1.0 Sender ok
S: 250 2.1.5 Recipient ok: <xxx@janwiesemann.de>
C: DATA
S: 354 3.0.0 Enter data for mail with id k86a7203DEJ6bdQ
C: From: Bitwarden <noreply@janwiesemann.de>
C: Date: Sat, 13 Apr 2024 16:19:05 +0200
C: Subject: How you doin'?
C: Message-Id: <638486219459348519@janwiesemann.de>
C: To: test <xxx@janwiesemann.de>
C: MIME-Version: 1.0
C: Content-Type: text/plain; charset=utf-8
C:
C: Bananenbrot
C: .
S: 250 2.0.0 OK queued with id k86a7203DEJ6bdQ
C: QUIT
S: 221 2.0.0 smtp.strato.com closing connection

Additional context Sending mails trough this address is possible. I'm already using it for Seafile (python using Django), FreePBX (postfix) and a few other systems.

If you need access to a test account I would be able to create one and mail it to you. In addition I've already contacted Strato.de but I haven't received a reply yet.

The following log is from my FreePBX system. I've received the message a few seconds later.

Apr 13 16:34:53 FreePBX postfix/master[7557]: daemon started -- version 2.10.1, configuration /etc/postfix
Apr 13 16:35:46 FreePBX postfix/pickup[7558]: 7A65896A489: uid=999 from=<asterisk@FreePBX.wieselan>
Apr 13 16:35:46 FreePBX postfix/cleanup[7960]: 7A65896A489: message-id=<661a984276154@FreePBX.wieselan>
Apr 13 16:35:46 FreePBX postfix/qmgr[7559]: 7A65896A489: from=<asterisk@FreePBX.wieselan>, size=1026, nrcpt=1 (queue active)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_stream_setup: maxtime=300 enable_deadline=0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 220 smtp.strato.de ESMTP RZmta (P9 -)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: > smtp.strato.de[81.169.145.133]:587: EHLO FreePBX.wieselan
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-smtp.strato.de greets 79.252.219.7
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-ENHANCEDSTATUSCODES
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-PIPELINING
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-8BITMIME
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-DELIVERBY
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-SIZE 104857600
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-LIMITS RCPTMAX=1000 MAILMAX=1000
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-STARTTLS
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250 HELP
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: server features: 0x101f size 104857600
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: Using ESMTP PIPELINING, TCP send buffer size is 46080, PIPELINING buffer size is 4096
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_stream_setup: maxtime=300 enable_deadline=0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: > smtp.strato.de[81.169.145.133]:587: STARTTLS
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 220 Ready to start TLS
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: send attr request = seed
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: send attr size = 32
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: private/tlsmgr: wanted attribute: status
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute name: status
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute value: 0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: private/tlsmgr: wanted attribute: seed
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute name: seed
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute value: xxx
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: private/tlsmgr: wanted attribute: (list terminator)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute name: (end)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_stream_setup: maxtime=300 enable_deadline=0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: > smtp.strato.de[81.169.145.133]:587: EHLO FreePBX.wieselan
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-smtp.strato.de greets 79.252.219.7
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-ENHANCEDSTATUSCODES
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-PIPELINING
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-8BITMIME
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-DELIVERBY
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-SIZE 104857600
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-LIMITS RCPTMAX=1000 MAILMAX=1000
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-AUTH PLAIN LOGIN CRAM-MD5 DIGEST-MD5
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250-REQUIRETLS
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250 HELP
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: server features: 0x102f size 104857600
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: Using ESMTP PIPELINING, TCP send buffer size is 46080, PIPELINING buffer size is 4096
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_sasl_passwd: smtp.strato.de: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_sasl_passwd: hash:/etc/postfix/sasl_passwd(0,lock|fold_fix): [smtp.strato.de]:587 = noreply@janwiesemann.de:xxx
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_sasl_passwd_lookup: host `smtp.strato.de' user `noreply@janwiesemann.de' pass `xxx'
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: starting new SASL client
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_sasl_authenticate: smtp.strato.de[81.169.145.133]:587: SASL mechanisms PLAIN LOGIN CRAM-MD5 DIGEST-MD5
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: xsasl_cyrus_client_get_user: noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: xsasl_cyrus_client_get_passwd: xxx
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: xsasl_cyrus_client_first: uncoded initial reply: \0noreply@janwiesemann.de\0xxx
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: > smtp.strato.de[81.169.145.133]:587: AUTH PLAIN xxx
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 235 2.7.0 OK Authenticated
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_stream_setup: maxtime=300 enable_deadline=0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: asterisk@FreePBX.wieselan: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: asterisk: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: hash:/etc/postfix/generic(0,lock|fold_fix): @FreePBX.wieselan = noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_find: asterisk@FreePBX.wieselan -> noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: connect to subsystem private/rewrite
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: send attr request = rewrite
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: send attr rule = local
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: send attr address = noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: private/rewrite socket: wanted attribute: flags
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute name: flags
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute value: 0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: private/rewrite socket: wanted attribute: address
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute name: address
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute value: noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: private/rewrite socket: wanted attribute: (list terminator)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: input attribute name: (end)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: rewrite_clnt: local: noreply@janwiesemann.de -> noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_map: asterisk@FreePBX.wieselan -> 0: noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_map11_external: asterisk@FreePBX.wieselan -> noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: > smtp.strato.de[81.169.145.133]:587: MAIL FROM:<noreply@janwiesemann.de> SIZE=1026 BODY=8BITMIME
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: xxx@janwiesemann.de: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: match_string: janwiesemann.de ~? FreePBX.wieselan
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: match_string: janwiesemann.de ~? localhost.wieselan
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: match_string: janwiesemann.de ~? localhost
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: match_list_match: janwiesemann.de: no match
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: @janwiesemann.de: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_find: xxx@janwiesemann.de -> (not found)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_map: xxx@janwiesemann.de -> (not found)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_map11_external: xxx@janwiesemann.de not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: > smtp.strato.de[81.169.145.133]:587: RCPT TO:<xxx@janwiesemann.de>
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: > smtp.strato.de[81.169.145.133]:587: DATA
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_stream_setup: maxtime=300 enable_deadline=0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250 2.1.0 Sender ok
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_stream_setup: maxtime=300 enable_deadline=0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250 2.1.5 Recipient ok: <xxx@janwiesemann.de>
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_stream_setup: maxtime=120 enable_deadline=0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 354 3.0.0 Enter data for mail with id k86a7203DEZkbfk
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_stream_setup: maxtime=180 enable_deadline=0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: xxx@janwiesemann.de: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: match_string: janwiesemann.de ~? FreePBX.wieselan
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: match_string: janwiesemann.de ~? localhost.wieselan
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: match_string: janwiesemann.de ~? localhost
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: match_list_match: janwiesemann.de: no match
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: @janwiesemann.de: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_find: xxx@janwiesemann.de -> (not found)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_map: xxx@janwiesemann.de -> (not found)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_map11_external: xxx@janwiesemann.de not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: asterisk@FreePBX.wieselan: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: asterisk: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: hash:/etc/postfix/generic(0,lock|fold_fix): @FreePBX.wieselan = noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_find: asterisk@FreePBX.wieselan -> noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: rewrite_clnt: cached: local: noreply@janwiesemann.de -> noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_map: asterisk@FreePBX.wieselan -> 0: noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_map11_external: asterisk@FreePBX.wieselan -> noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: asterisk@FreePBX.wieselan: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: asterisk: not found
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: maps_find: smtp_generic_maps: hash:/etc/postfix/generic(0,lock|fold_fix): @FreePBX.wieselan = noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_find: asterisk@FreePBX.wieselan -> noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: rewrite_clnt: cached: local: noreply@janwiesemann.de -> noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: mail_addr_map: asterisk@FreePBX.wieselan -> 0: noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_map11_external: asterisk@FreePBX.wieselan -> noreply@janwiesemann.de
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: > smtp.strato.de[81.169.145.133]:587: .
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: > smtp.strato.de[81.169.145.133]:587: QUIT
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: smtp_stream_setup: maxtime=600 enable_deadline=0
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: < smtp.strato.de[81.169.145.133]:587: 250 2.0.0 OK queued with id k86a7203DEZkbfk
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: 7A65896A489: to=<xxx@janwiesemann.de>, relay=smtp.strato.de[81.169.145.133]:587, delay=0.32, delays=0.02/0.01/0.11/0.18, dsn=2.0.0, status=sent (250 2.0.0 OK queued with id k86a7203DEZkbfk)
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: name_mask: resource
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: name_mask: software
Apr 13 16:35:46 FreePBX postfix/smtp[7962]: disposing SASL state information
Apr 13 16:35:46 FreePBX postfix/qmgr[7559]: 7A65896A489: removed
jstedfast commented 2 months ago

Looks like a duplicate of https://github.com/jstedfast/MailKit/issues/1737

jstedfast commented 2 months ago

I need to make a new release but I've just been busy.

janwiesemann commented 2 months ago

1737 provides a workaround

jstedfast commented 2 months ago

I just released MailKit v4.5.0 with the fix for this.