The write operation failed

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
nicolasft
New user
New user
Posts: 20
Joined: 2019-03-27 20:44

The write operation failed

Post by nicolasft » 2020-04-23 19:07

Hello everyone I'm having the following error below:

"The write operation failed. Bytes transferred: 16384 Remote IP: XXXXXXXXX, Session: 7, Code: 10054, Message: An existing connection was forcibly closed by the remote host"

However, this error only occurs when sending an email with attached file, if the email has nothing attached or only text is sent successfully, any suggestions?

User avatar
Dravion
Senior user
Senior user
Posts: 1688
Joined: 2015-09-26 11:50
Location: Germany
Contact:

Re: The write operation failed

Post by Dravion » 2020-04-23 19:22

The Error is a Client side triggered event.

However, this can also be triggered by a interference of some sort of a third party program on your hMailServer Computer, like a Antivirus Program on your hMailServer\DATA folder. Make sure nothing blocks the folder so hMailServer.exe can read/write/edit and delete any file and folder in it
(pause your AV-Software or Exclude your hMailServer DATA folder and try again and report back.

nicolasft
New user
New user
Posts: 20
Joined: 2019-03-27 20:44

Re: The write operation failed

Post by nicolasft » 2020-04-23 19:33

Hello,
So I think it's something else
This computer only has HMAILSERVER installed, I removed everything on windows, firewall, windows defender, is there anything else that could be ??

User avatar
Dravion
Senior user
Senior user
Posts: 1688
Joined: 2015-09-26 11:50
Location: Germany
Contact:

Re: The write operation failed

Post by Dravion » 2020-04-23 20:28

The information provided allows the following assessment:

You said, its happening while you trying to send an Email, so this is an SMTP-Protocol operation on port 465 SSL/TLS or Port 587 STARTTLS or
without encryption. But this is irrelevant, because the connection was successfully created between your Email program and hMailServer SMTPD.
We are talking about a SMTP Command sequence fail.

EHLO is ok, or the Error message would be a differen't one
MAIL FROM: is ok, or the Error message would be a differen't one
RCPT TO: is ok, or the Error message would be a differen't one

So, there is only the SMTP "DATA" and SMTP "." Command left before the operation is complete, but this never happens.
and your Email Client waits forever until a Timeout kicks in and your Email program terminates the connection to hMailServer by force.

Ok, this means that the receive part of the attachment data chunk (which is a Base64 Encoded string) is blocked BEFORE it was successfully
received and written to an *.eml Message file by hMailServer.

This could be a bug of your Email program.

Try the same with a different Email program and report back.

nicolasft
New user
New user
Posts: 20
Joined: 2019-03-27 20:44

Re: The write operation failed

Post by nicolasft » 2020-04-23 20:36

Hello,
In the .EML file created in the DATA folder, it is correct,
If I try to open it in my email program it opens the email normally with the attachment,
In other words, the email was created successfully, but something is preventing it from transmitting to the remote server,
Since if I don't attach anything to the email it successfully transmits,
Is there any configuration on hMailServer that may be impacting?

nicolasft
New user
New user
Posts: 20
Joined: 2019-03-27 20:44

Re: The write operation failed

Post by nicolasft » 2020-04-23 20:40

I will send the complete error log
------------

Code: Select all

"DEBUG"	984	"2020-04-23 15:24:39.938"	"Creating session 4"
"TCPIP"	984	"2020-04-23 15:24:39.938"	"TCP - 10.10.10.10 connected to 10.10.10.20:8027."
"DEBUG"	984	"2020-04-23 15:24:39.954"	"TCP connection started for session 3"
"SMTPD"	984	3	"2020-04-23 15:24:39.954"	"10.10.10.10"	"SENT: 220 XXXXXXXXXXXXXXXXX"
"SMTPD"	516	3	"2020-04-23 15:24:40.016"	"10.10.10.10"	"RECEIVED: EHLO TCSHLSPOA1AC09"
"SMTPD"	516	3	"2020-04-23 15:24:40.016"	"10.10.10.10"	"SENT: 250-mx7.XXXXXXXXXXXXX[nl]250-SIZE 20480000[nl]250-AUTH LOGIN PLAIN[nl]250 HELP"
"SMTPD"	5348	3	"2020-04-23 15:24:40.091"	"10.10.10.10"	"RECEIVED: AUTH login dGVzdGVAdGNzZGlnaXRhbC5jb20uYnI="
"SMTPD"	5348	3	"2020-04-23 15:24:40.091"	"10.10.10.10"	"SENT: 334 UGFzc3dvcmQ6"
"SMTPD"	984	3	"2020-04-23 15:24:40.169"	"10.10.10.10"	"RECEIVED: ***"
"SMTPD"	984	3	"2020-04-23 15:24:40.169"	"10.10.10.10"	"SENT: 235 authenticated."
"SMTPD"	516	3	"2020-04-23 15:24:40.247"	"10.10.10.10"	"RECEIVED: MAIL FROM:<teste@XXXXXXXXXXXX>"
"SMTPD"	516	3	"2020-04-23 15:24:40.247"	"10.10.10.10"	"SENT: 250 OK"
"SMTPD"	5348	3	"2020-04-23 15:24:40.341"	"10.10.10.10"	"RECEIVED: RCPT TO:<nicolas@XXXXXXXXXXXX>"
"SMTPD"	5348	3	"2020-04-23 15:24:40.341"	"10.10.10.10"	"SENT: 250 OK"
"SMTPD"	984	3	"2020-04-23 15:24:40.419"	"10.10.10.10"	"RECEIVED: DATA"
"SMTPD"	984	3	"2020-04-23 15:24:40.419"	"10.10.10.10"	"SENT: 354 OK, send."
"DEBUG"	984	"2020-04-23 15:24:41.732"	"Could not retrieve PTR record for IP (false)! 10.10.10.10"
"DEBUG"	3700	"2020-04-23 15:24:42.040"	"Adding task AsynchronousTask to work queue Asynchronous task queue"
"DEBUG"	5688	"2020-04-23 15:24:42.040"	"Executing task AsynchronousTask in work queue Asynchronous task queue"
"DEBUG"	5688	"2020-04-23 15:24:42.040"	"Saving message: {E4D9205E-A7FA-4B37-9BAF-9E5D1676CEC1}.eml"
"DEBUG"	5688	"2020-04-23 15:24:42.056"	"Requesting SMTPDeliveryManager to start message delivery"
"SMTPD"	5688	3	"2020-04-23 15:24:42.056"	"10.10.10.10"	"SENT: 250 Queued (1.625 seconds)"
"DEBUG"	1520	"2020-04-23 15:24:42.056"	"Adding task DeliveryTask to work queue SMTP delivery queue"
"DEBUG"	4956	"2020-04-23 15:24:42.056"	"Executing task DeliveryTask in work queue SMTP delivery queue"
"DEBUG"	4956	"2020-04-23 15:24:42.056"	"Delivering message..."
"APPLICATION"	4956	"2020-04-23 15:24:42.056"	"SMTPDeliverer - Message 20: Delivering message from teste@XXXXXXXXXXXX to nicolas@XXXXXXXXXXXX. File: C:\DATA\{E4D9205E-A7FA-4B37-9BAF-9E5D1676CEC1}.eml"
"DEBUG"	4956	"2020-04-23 15:24:42.087"	"Applying rules"
"DEBUG"	4956	"2020-04-23 15:24:42.087"	"Performing local delivery"
"DEBUG"	4956	"2020-04-23 15:24:42.087"	"Local delivery completed"
"DEBUG"	4956	"2020-04-23 15:24:42.087"	"Signing message using DKIM..."
"TCPIP"	4956	"2020-04-23 15:24:42.134"	"DNS MX lookup: XXXXXXXXXXXX"
"TCPIP"	4956	"2020-04-23 15:24:42.275"	"DNS - MX Result: 2 IP addresses were found."
"DEBUG"	4956	"2020-04-23 15:24:42.275"	"Starting external delivery process. Server: XXXXXXXXXXXX-com-br.mail.protection.outlook.com (XXXXXXXXXXXX), Port: 25, Security: 2, User name: "
"DEBUG"	4956	"2020-04-23 15:24:42.275"	"Creating session 5"
"TCPIP"	4956	"2020-04-23 15:24:42.275"	"Connecting to XXXXXXXXXXXX:25..."
"DEBUG"	5348	"2020-04-23 15:24:42.387"	"TCP connection started for session 5"
"SMTPC"	5348	5	"2020-04-23 15:24:42.497"	"XXXXXXXXXXXX"	"RECEIVED: 220 BN7NAM10FT018.mail.protection.outlook.com Microsoft ESMTP MAIL Service ready at Thu, 23 Apr 2020 18:24:41 +0000"
"SMTPC"	5348	5	"2020-04-23 15:24:42.497"	"XXXXXXXXXXXX"	"SENT: EHLO mx7.XXXXXXXXXXXX"
"SMTPC"	984	5	"2020-04-23 15:24:42.622"	"XXXXXXXXXXXX"	"RECEIVED: 250-BN7NAM10FT018.mail.protection.outlook.com Hello [XXXXXXXXXXXX][nl]250-SIZE 157286400[nl]250-PIPELINING[nl]250-DSN[nl]250-ENHANCEDSTATUSCODES[nl]250-STARTTLS[nl]250-8BITMIME[nl]250-BINARYMIME[nl]250-CHUNKING[nl]250 SMTPUTF8"
"SMTPC"	984	5	"2020-04-23 15:24:42.622"	"XXXXXXXXXXXX"	"SENT: STARTTLS"
"SMTPC"	3700	5	"2020-04-23 15:24:42.736"	"XXXXXXXXXXXX"	"RECEIVED: 220 2.0.0 SMTP server ready"
"DEBUG"	3700	"2020-04-23 15:24:42.736"	"Performing SSL/TLS handshake for session 5. Verify certificate: True, Expected remote host name: XXXXXXXXXXXX-com-br.mail.protection.outlook.com"
"DEBUG"	516	"2020-04-23 15:24:42.880"	"Certificate verification succeeded for session 5."
"TCPIP"	3700	"2020-04-23 15:24:42.989"	"TCPConnection - TLS/SSL handshake completed. Session Id: 5, Remote IP: XXXXXXXXXXXX, Version: TLSv1.2, Cipher: ECDHE-RSA-AES256-GCM-SHA384, Bits: 256"
"SMTPC"	3700	5	"2020-04-23 15:24:42.989"	"XXXXXXXXXXXX"	"SENT: EHLO mx7.XXXXXXXXXXXX"
"SMTPC"	984	5	"2020-04-23 15:24:43.116"	"XXXXXXXXXXXX"	"RECEIVED: 250-BN7NAM10FT018.mail.protection.outlook.com Hello [XXXXXXXXXXXX][nl]250-SIZE 157286400[nl]250-PIPELINING[nl]250-DSN[nl]250-ENHANCEDSTATUSCODES[nl]250-8BITMIME[nl]250-BINARYMIME[nl]250-CHUNKING[nl]250 SMTPUTF8"
"SMTPC"	984	5	"2020-04-23 15:24:43.116"	"XXXXXXXXXXXX"	"SENT: MAIL FROM:<teste@XXXXXXXXXXXX>"
"SMTPC"	4148	5	"2020-04-23 15:24:43.272"	"XXXXXXXXXXXX"	"RECEIVED: 250 2.1.0 Sender OK"
"SMTPC"	4148	5	"2020-04-23 15:24:43.272"	"XXXXXXXXXXXX"	"SENT: RCPT TO:<nicolas@XXXXXXXXXXXX>"
"SMTPC"	2388	5	"2020-04-23 15:24:43.460"	"XXXXXXXXXXXX"	"RECEIVED: 250 2.1.5 Recipient OK"
"SMTPC"	2388	5	"2020-04-23 15:24:43.460"	"XXXXXXXXXXXX"	"SENT: DATA"
"SMTPC"	984	5	"2020-04-23 15:24:43.569"	"XXXXXXXXXXXX"	"RECEIVED: 354 Start mail input; end with <CRLF>.<CRLF>"
"DEBUG"	2800	"2020-04-23 15:25:02.897"	"The write operation failed. Bytes transferred: 16384 Remote IP: XXXXXXXXXXXX, Session: 5, Code: 10054, Message: An existing connection was forcibly closed by the remote host"
"DEBUG"	2800	"2020-04-23 15:25:02.897"	"Ending session 5"
"DEBUG"	4956	"2020-04-23 15:25:02.897"	"External delivery process completed"
"DEBUG"	4956	"2020-04-23 15:25:02.897"	"Starting external delivery process. Server: XXXXXXXXXXXX-com-br.mail.protection.outlook.com (XXXXXXXXXXXX), Port: 25, Security: 2, User name: "
"DEBUG"	4956	"2020-04-23 15:25:02.897"	"Creating session 6"
"TCPIP"	4956	"2020-04-23 15:25:02.897"	"Connecting to XXXXXXXXXXXX:25..."
"DEBUG"	984	"2020-04-23 15:25:03.069"	"TCP connection started for session 6"

User avatar
Dravion
Senior user
Senior user
Posts: 1688
Joined: 2015-09-26 11:50
Location: Germany
Contact:

Re: The write operation failed

Post by Dravion » 2020-04-23 21:07

Ok, you are using a Office 365 Relay server.

It looks like, this SMTP Relay server checks if a Attachment is part of your Email and rejects it of some unknown reason.


This one...
"DEBUG" 2800 "2020-04-23 15:25:02.897" "The write operation failed. Bytes transferred: 16384 Remote IP: XXXXXXXXXXXX, Session: 5, Code: 10054, Message: An existing connection was forcibly closed by the remote host"
Is especially interesting.
Because it transfers exactly 16384 to the Office 365 Remote SMTP Relay server before it cancels the Email entirely transmission completely.
So, its a halfway transmission before Microsoft says no and good bye.

Can you check your attachment by uploading it to https://www.virustotal.com and reporting the results?

nicolasft
New user
New user
Posts: 20
Joined: 2019-03-27 20:44

Re: The write operation failed

Post by nicolasft » 2020-04-23 21:41

Hello
I am not using a "Relay Server"
I'm sending the email to an Office 365 account, but if I send it to any other, the problem is the same

This is what I find strange, this seems to be the exact size of the message, that is, it sends the entire message, but in the end it cancels the sending

I sent the attachment to virustotal.com and returned the following No engines detected this file, Undetected

It's a PDF file

Another important information if I try to send this file from another installation of Hmailserver sends successfully, then it is some configuration or something of the kind that I am not able to identify

User avatar
mattg
Moderator
Moderator
Posts: 21106
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: The write operation failed

Post by mattg » 2020-04-24 04:22

It could be an edge device, or a firewall device on your network that is 'inspecting' mail

It could be many things...
Are you sure that there is no local Antivirus on the machine with hmailserver installed
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
Dravion
Senior user
Senior user
Posts: 1688
Joined: 2015-09-26 11:50
Location: Germany
Contact:

Re: The write operation failed

Post by Dravion » 2020-04-24 09:47

nicolasft wrote:
2020-04-23 21:41
Hello
I am not using a "Relay Server"
I'm sending the email to an Office 365 account, but if I send it to any other, the problem is the same
Hold on:
Do you have a Office 365 Exchange Online Account and/or do you have your Domain of your Company/Organization registered with Office 365?
OR
Do you have a primary Email address registered with Office 365 which do you fetch new Emails and send Emails with via hMailServer?
This is what I find strange, this seems to be the exact size of the message, that is, it sends the entire message, but in the end it cancels the sending
As a programmer, i find this behavior logical, because you need the entire Attachment as a file to blacklist or whitelist something.
Another important information if I try to send this file from another installation of Hmailserver sends successfully, then it is some configuration or something of the kind that I am not able to identify
Web hosting Enterprise Packages like Office 365 with or without Exchange Online have their own rules what they accept and what not. If you have Exchange Online, you maybe need to configure the Relay feature correctly with a SSL-Certificate and/or whitelist your sending NAT-Router DHCP ip address with Office 365.

Summary:
This is not a hMailServer problem or fault.
You having a Problem with Microsoft Office 365.
You should contact Microsoft Support and ask them why your Office 365 Account allows certain Email with PDF attachments while others
are rejected.

User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Re: The write operation failed

Post by jimimaseye » 2020-04-24 09:59

Dravion wrote:
2020-04-24 09:47
Summary:
You having a Problem with Microsoft Office 365.
You should contact Microsoft Support and ask them why your Office 365 Account allows certain Email with PDF attachments while others
He had already said it is nothing to do with office 365:
nicolasft wrote:
2020-04-23 21:41
I am not using a "Relay Server"
I'm sending the email to an Office 365 account, but if I send it to any other, the problem is the same
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
Dravion
Senior user
Senior user
Posts: 1688
Joined: 2015-09-26 11:50
Location: Germany
Contact:

Re: The write operation failed

Post by Dravion » 2020-04-24 10:11

jimimaseye wrote:
2020-04-24 09:59
Dravion wrote:
2020-04-24 09:47
Summary:
You having a Problem with Microsoft Office 365.
You should contact Microsoft Support and ask them why your Office 365 Account allows certain Email with PDF attachments while others
He had already said it is nothing to do with office 365:
nicolasft wrote:
2020-04-23 21:41
I am not using a "Relay Server"
I'm sending the email to an Office 365 account, but if I send it to any other, the problem is the same
Regardless if its not possible to reach a Office 365 Inbox or its a Office 365 Enterprise Online issue, the solution to this problem is still the same:

Contact Microsoft Support and ask them why your Office 365 Account allows certain Email with PDF attachments to pass while others
with a PDF are rejected.

User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Re: The write operation failed

Post by jimimaseye » 2020-04-24 10:33

Dravion wrote:
2020-04-24 10:11
jimimaseye wrote:
2020-04-24 09:59
Dravion wrote:
2020-04-24 09:47
Summary:
You having a Problem with Microsoft Office 365.
You should contact Microsoft Support and ask them why your Office 365 Account allows certain Email with PDF attachments while others
He had already said it is nothing to do with office 365:
nicolasft wrote:
2020-04-23 21:41
I am not using a "Relay Server"
I'm sending the email to an Office 365 account, but if I send it to any other, the problem is the same
Regardless if its not possible to reach a Office 365 Inbox or its a Office 365 Enterprise Online issue, the solution to this problem is still the same:

Contact Microsoft Support and ask them why your Office 365 Account allows certain Email with PDF attachments to pass while others
with a PDF are rejected.
.... and expect them to come back with "We don't. It's nothing to do with us". You are wasting your time with this advice. They're is no point asking them about an event that happens with other recipient servers too (as claimed, if true) . Logic should tell you that the issue is now localised to you rather than with every recipient server you send these emails too.

As the comms are dropped by something external to it, hms will only ever think it'send report it's 'the remote server' - it will never know it was AV or edge device interfering.

My guess there is an intermediary monitoring and dropping when a size limit is exceeded. So stick with the relevant advice of:
mattg wrote:
2020-04-24 04:22
It could be an edge device, or a firewall device on your network that is 'inspecting' mail

It could be many things...
Are you sure that there is no local Antivirus on the machine with hmailserver installed
[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

nicolasft
New user
New user
Posts: 20
Joined: 2019-03-27 20:44

Re: The write operation failed

Post by nicolasft » 2020-04-24 15:30

mattg wrote:
2020-04-24 04:22
It could be an edge device, or a firewall device on your network that is 'inspecting' mail

It could be many things...
Are you sure that there is no local Antivirus on the machine with hmailserver installed
Hello
There is no antivirus, the machine is Windows 2019 Server with hMailServer, I disabled the windows antivirus and the firewall,

What I know is that there is a PfSense Firewall on the network, but they claim that this with the ports all released, can it be something in PfSense?

nicolasft
New user
New user
Posts: 20
Joined: 2019-03-27 20:44

Re: The write operation failed

Post by nicolasft » 2020-04-24 15:31

jimimaseye wrote:
2020-04-24 10:33
Dravion wrote:
2020-04-24 10:11
jimimaseye wrote:
2020-04-24 09:59


He had already said it is nothing to do with office 365:

Regardless if its not possible to reach a Office 365 Inbox or its a Office 365 Enterprise Online issue, the solution to this problem is still the same:

Contact Microsoft Support and ask them why your Office 365 Account allows certain Email with PDF attachments to pass while others
with a PDF are rejected.
.... and expect them to come back with "We don't. It's nothing to do with us". You are wasting your time with this advice. They're is no point asking them about an event that happens with other recipient servers too (as claimed, if true) . Logic should tell you that the issue is now localised to you rather than with every recipient server you send these emails too.

As the comms are dropped by something external to it, hms will only ever think it'send report it's 'the remote server' - it will never know it was AV or edge device interfering.

My guess there is an intermediary monitoring and dropping when a size limit is exceeded. So stick with the relevant advice of:
mattg wrote:
2020-04-24 04:22
It could be an edge device, or a firewall device on your network that is 'inspecting' mail

It could be many things...
Are you sure that there is no local Antivirus on the machine with hmailserver installed
[Entered by mobile. Excuse my spelling.]
Exactly,
If I send to Gmail, yahoo, any other the same error is shown in the log, it is not something specific to Office 365,

User avatar
mattg
Moderator
Moderator
Posts: 21106
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: The write operation failed

Post by mattg » 2020-04-25 01:17

nicolasft wrote:
2020-04-24 15:30
What I know is that there is a PfSense Firewall on the network, but they claim that this with the ports all released, can it be something in PfSense?
Certainly could be

I have PFSense too and it's great, but it can do weird things at times
DO you have snort enabled on your PF sense?
Do you run an internet proxy on it?
Are you running antivirus or doing any mail inspections for spam etc on it
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

nicolasft
New user
New user
Posts: 20
Joined: 2019-03-27 20:44

Re: The write operation failed

Post by nicolasft » 2020-04-30 20:03

Problem solved!
In fact the problem was in the PfSense Firewall, but as the machine is rented from a datacenter, I'm not sure what they did to fix it,
but after much insistence some settings changed and the problem solved, it must be something very specific that they have configured!

User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Re: The write operation failed

Post by jimimaseye » 2020-04-30 22:41

Good. Well done.

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Post Reply