# Sendmail exception "Operation on non-blocking socket would block"

**URL:** https://forum.duplicati.com/t/sendmail-exception-operation-on-non-blocking-socket-would-block/11364
**Category:** Support
**Tags:** bug
**Created:** [December 17, 2020, 10:16am UTC](https://forum.duplicati.com/t/sendmail-exception-operation-on-non-blocking-socket-would-block/11364 "2020-12-17T10:16:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Haron](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/h/13edae/32.png) [@Haron](https://forum.duplicati.com/u/Haron)
#### Post date: [December 17, 2020, 10:16am UTC](https://forum.duplicati.com/t/sendmail-exception-operation-on-non-blocking-socket-would-block/11364/1 "2020-12-17T10:16:30Z")

</div>

Hi,

Duplicati 2.0.5.1\_beta\_2020-01-18 on macOS 10.13

Sendmail config:

```
      {
        "Filter": "",
        "Name": "--send-mail-url",
        "Value": "smtp://smtp.mail.ru:465/?starttls=when-available",
        "Argument": null
      },
      {
        "Filter": "",
        "Name": "--send-mail-username",
        "Value": "<me>@mail.ru",
        "Argument": null
      },
      {
        "Filter": "",
        "Name": "--send-mail-password",
        "Value": "<password>",
        "Argument": null
      },
      {
        "Filter": "",
        "Name": "--send-mail-to",
        "Value": "<me>@mail.ru",
        "Argument": null
      }

```

Log:

```
2020-12-17 21:07:45 +11 - [Warning-Duplicati.Library.Modules.Builtin.ReportHelper-ReportSubmitError]: Failed to send message: System.IO.IOException: Operation on non-blocking socket would block
--> System.Net.Sockets.SocketException: Operation on non-blocking socket would block

System.IO.IOException: Operation on non-blocking socket would block ---> System.Net.Sockets.SocketException: Operation on non-blocking socket would block
  at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00016] in <d6a60aa59c7e453abe17968d3649bb29>:0 
  at MailKit.Net.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00000] in <044c7cb38b61487086ccf0eae49cb447>:0 
   --- End of inner exception stack trace ---
  at MailKit.Net.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x0001f] in <044c7cb38b61487086ccf0eae49cb447>:0 
  at MailKit.Net.Smtp.SmtpStream.ReadAheadAsync (System.Boolean doAsync, System.Threading.CancellationToken cancellationToken) [0x0025a] in <044c7cb38b61487086ccf0eae49cb447>:0 
  at MailKit.Net.Smtp.SmtpStream.ReadResponseAsync (System.Boolean doAsync, System.Threading.CancellationToken cancellationToken) [0x000bd] in <044c7cb38b61487086ccf0eae49cb447>:0 
  at MailKit.Net.Smtp.SmtpStream.ReadResponse (System.Threading.CancellationToken cancellationToken) [0x0000e] in <044c7cb38b61487086ccf0eae49cb447>:0 
  at (wrapper remoting-invoke-with-check) MailKit.Net.Smtp.SmtpStream.ReadResponse(System.Threading.CancellationToken)
  at MailKit.Net.Smtp.SmtpClient.ConnectAsync (System.String host, System.Int32 port, MailKit.Security.SecureSocketOptions options, System.Boolean doAsync, System.Threading.CancellationToken cancellationToken) [0x0068a] in <044c7cb38b61487086ccf0eae49cb447>:0 
  at Duplicati.Library.Modules.Builtin.SendMail.SendMessage (System.String subject, System.String body) [0x00581] in <04c2b0910a9b45e2b6ef4f090eeb7063>:0 
  at Duplicati.Library.Modules.Builtin.ReportHelper.OnFinish (System.Object result) [0x00135] in <04c2b0910a9b45e2b6ef4f090eeb7063>:0 

```

Ideas?

Thank you

---

<div class="post-metadata">

### Author: ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)
#### Post date: [December 19, 2020, 5:35pm UTC](https://forum.duplicati.com/t/sendmail-exception-operation-on-non-blocking-socket-would-block/11364/2 "2020-12-19T17:35:06Z")

</div>

> [@Haron](#):
>
> Ideas?

For STARTTLS you generally use port 25 or 587. The initial connection is not encrypted, but it can switch.  
Port 465 is generally encrypted implicitly, so maybe the mismatched setup is producing socket confusion.

You could try `smtps://smtp.mail.ru:465` or  
`smtp://smtp.mail.ru:587/?starttls=when-available` (or `always` if you want to insist on encryption)

---

<div class="post-metadata">

### Author: ![Haron](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/h/13edae/32.png) [@Haron](https://forum.duplicati.com/u/Haron)
#### Post date: [December 19, 2020, 9:09pm UTC](https://forum.duplicati.com/t/sendmail-exception-operation-on-non-blocking-socket-would-block/11364/3 "2020-12-19T21:09:01Z")

</div>

Yeah, those multipli SMTP(S) connection options ARE frustrating…  
Anyway, this worked: `smtp://smtp.mail.ru:587/?starttls=when-available`  
Thank you very much!
