Sending to Postal SMTP fails in MailKit 3.4.2
See original GitHub issueDescribe the bug I’m trying to send emails to Postal (self-hosts SES alternative, more or less) via SMTP. This worked without a problem in MailKit 3.4.1 but stopped working in 3.4.2. On the server I can see the EHLO, but the connection is closed afterwards. The behaviour is the same with and without TLS enabled. I’d be happy to provide credentials for a test-organization in a private message/email.
Platform (please complete the following information):
- OS: Windows 11, Windows Server 2019
- .NET Runtime: CoreCLR
- .NET Framework: .NET 7.0
- MailKit Version: 3.4.2
Exception
Unhandled exception. MailKit.Net.Smtp.SmtpProtocolException: Unable to parse status code returned by the server.
at MailKit.Net.Smtp.SmtpStream.ReadResponse(ByteArrayBuilder builder, Boolean& newLine, Boolean& more, Int32& code)
at MailKit.Net.Smtp.SmtpStream.ReadResponseAsync(CancellationToken cancellationToken)
at MailKit.Net.Smtp.SmtpStream.SendCommandAsync(String command, CancellationToken cancellationToken)
at MailKit.Net.Smtp.SmtpClient.EhloAsync(CancellationToken cancellationToken)
at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, CancellationToken cancellationToken)
at Program.<Main>$(String[] args) in C:\Users\stipps\RiderProjects\MailTester\MailTester\Program.cs:line 15
at Program.<Main>(String[] args)
To Reproduce Steps to reproduce the behavior:
- Setup Postal instance (https://docs.postalserver.io/install/installation)
- Create .NET console application
- Add minimal code to send email over postal smtp
- See error
Expected behavior MailKit connects to the server and sends the email.
Code Snippets If applicable, add code snippets to help explain your problem.
using MailKit;
using MailKit.Net.Smtp;
using MailKit.Security;
using MimeKit;
var msg = new MimeMessage();
msg.From.Add(InternetAddress.Parse("hello@mydomain.com"));
msg.To.Add(InternetAddress.Parse("frs@yourdomain.com"));
msg.Subject = "Ihre Bestellung im Shop";
var bb = new BodyBuilder();
bb.TextBody = "Vielen Dank fuer Ihre Bestellung!";
msg.Body = bb.ToMessageBody();
var client = new SmtpClient();
await client.ConnectAsync("mailer.mydomain.com", 25, SecureSocketOptions.Auto);
await client.AuthenticateAsync("myorg/mydomain", "mypassword");
await client.SendAsync(msg);
await client.DisconnectAsync(true);
Protocol Logs
Connected to smtp://mailer.mydomain.com:25/?starttls=when-available
S: 220 mailer.haarhoff.eu ESMTP Postal/DPNZMRC: EHLO TICK
After this the exception is thrown.
Postal SMTP log:
postal-smtp-1 | [9] [2022-11-18T07:46:55.818] DEBUG -- : [YWMLLX] Connection opened from ::ffff:176.199.38.70
postal-smtp-1 | [9] [2022-11-18T07:46:55.818] DEBUG -- : [YWMLLX] Client identified as ::ffff:176.199.38.70
postal-smtp-1 | [9] [2022-11-18T07:46:55.839] DEBUG -- : [YWMLLX] <= EHLO TICK
postal-smtp-1 | [9] [2022-11-18T07:46:55.843] DEBUG -- : [YWMLLX] => 250-My capabilities are
postal-smtp-1 | [9] [2022-11-18T07:46:55.843] DEBUG -- : [YWMLLX] => 250-STARTTLS
postal-smtp-1 | [9] [2022-11-18T07:46:55.843] DEBUG -- : [YWMLLX] => 250 AUTH CRAM-MD5 PLAIN LOGIN
postal-smtp-1 | [9] [2022-11-18T07:46:55.856] DEBUG -- : [YWMLLX] Connection closed
Issue Analytics
- State:
- Created 10 months ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
MailKit 3.4.2 - "535: 5.7.3 Authentication unsuccessful"
I am trying to send mail to a client's Exchange server that uses NTLM authentication and am getting a "535: 5.7.3 Authentication unsuccessful" ......
Read more >MailKit SmtpClient Performance issue #1408
I was hoping that MailKit would send emails faster than System.Net.Mail. The reason being, is that System.Net.Mail in .net 6 is 5 times ......
Read more >Common Errors When Sending Email With Mailkit
Common Errors When Sending Email With Mailkit · Default Ports · Incorrect SMTP Host · Incorrect SMTP Port · Forcing Non-SSL On An...
Read more >Everything you need to know about SMTP Error Codes
SMTP is used to send emails across the network with the help of MTA. Here in this tutorial we will go through the...
Read more >SMTP Send mail Error Mail.Kit security authentication ...
Hi, i'm trying to send Emails using SMTP and i keep receiving this exception i appreciate your support Thanks.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Awesome, thanks for testing my changes! I’ll try to make a new 3.4.3 release by early next week (after the holidays).
Looks good, all my tests with our Postal server are now able to connect and send using that latest commit. Thank you!