How to log headers sent during SMTP client session?

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
beiley
New user
New user
Posts: 14
Joined: 2016-09-14 16:43
Location: AZ in the US
Contact:

How to log headers sent during SMTP client session?

Post by beiley » 2021-03-26 22:27

I need a copy of the email headers sent in an SMTP client session. I've enabled SMTP logging, but those logs don't show all the detailed headers being sent. How can I do this?

Thanks,
Mark

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

Re: How to log headers sent during SMTP client session?

Post by mattg » 2021-03-27 23:23

headers sent in a SMTP client session?
Perhaps use Wireshark or something similar
I'm really not sure what you will find though


Message headers will normally be part of a message, but I suspect that you are looking for something else

Can you provide more detail on EXACTLY what you are looking for
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

beiley
New user
New user
Posts: 14
Joined: 2016-09-14 16:43
Location: AZ in the US
Contact:

Re: How to log headers sent during SMTP client session?

Post by beiley » 2021-03-28 17:08

I'm trying to get a complete copy of the mail headers from an email that failed to be delivered. The mail was accepted for delivery by hMailServer, but when hMailServer tried to relay it to its final destination, that destination mail server (Yahoo) refused to accept it, and issued an error message. A bounced email was returned to the original sender. I'm trying to work with Yahoo's postmaster (the final destination mail server) to get the problem corrected, and they are asking me for:
to provide us with the full headers of a recent email sent to a Yahoo Mail account that experienced delivery problems
I can only get this from the hMailServer logs:

Code: Select all

"SMTPC" 2192 13993 "2021-03-25 19:23:15.374" "98.136.96.74" "RECEIVED: 250-mtaproxy209.free.mail.ne1.yahoo.com[nl]250-PIPELINING[nl]250-SIZE 41943040[nl]250-8BITMIME[nl]250 OK"
"SMTPC" 2192 13993 "2021-03-25 19:23:15.374" "98.136.96.74" "SENT: MAIL FROM:<announcement@fundmanagersoftware.com>"
"SMTPC" 2204 13993 "2021-03-25 19:23:15.436" "98.136.96.74" "RECEIVED: 421 4.7.0 [TSS04] Messages from 54.68.144.214 temporarily deferred due to unexpected volume or user complaints - 4.16.55.1; see https://postmaster.verizonmedia.com/error-codes"
"SMTPC" 2204 13993 "2021-03-25 19:23:15.436" "98.136.96.74" "SENT: QUIT"
I have the mail headers from the email as originally sent to hMailServer. I have the bounced message, but it doesn't include the original email/headers sent to Yahoo. I'd like to have a log of the communication between hMailServer and Yahoo's mail server, showing the exact headers sent/refused. Or, maybe there were no headers even attempted to be sent in this case? Maybe Yahoo rejected the message before headers were even sent (at the MAIL FROM: command)?

Thank you,
Mark

User avatar
jim.bus
Senior user
Senior user
Posts: 1571
Joined: 2011-05-28 11:49
Location: US

Re: How to log headers sent during SMTP client session?

Post by jim.bus » 2021-03-28 22:55

If you are not already doing so you should select all the hMailServer Logs and look at them after recreating the problem. The full set of Logs may give you the necessary information. The Log Entries you show seem to indicate a problem with mail sent to a Verizon Postmaster indicating a possible Volume issue or perhaps user complaints.
If you think you understand quantum mechanics, you don't understand quantum mechanics.

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

Re: How to log headers sent during SMTP client session?

Post by mattg » 2021-03-29 01:40

Can you ask the original sender for a copy of the message that they sent?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

beiley
New user
New user
Posts: 14
Joined: 2016-09-14 16:43
Location: AZ in the US
Contact:

Re: How to log headers sent during SMTP client session?

Post by beiley » 2021-03-29 01:46

Yes, I understand the reason for the error message. We were sending out an email announcement, and Yahoo saw a large spike in volume. I'm just trying to provide Yahoo what they've asked for, which are the mail headers from one of these rejected messages. I did turn on all logging, and couldn't find such a low level detailed log of all communications sent/received during an SMTP session. I'm not sure even how far the communication gets, before getting the rejected message. Is it rejecting it on the MAIL FROM command, or on the DATA command? I don't seem to be able to figure out this level of detail from the available logs.

beiley
New user
New user
Posts: 14
Joined: 2016-09-14 16:43
Location: AZ in the US
Contact:

Re: How to log headers sent during SMTP client session?

Post by beiley » 2021-03-29 01:47

mattg wrote:
2021-03-29 01:40
Can you ask the original sender for a copy of the message that they sent?
I am the original sender, and yes, I do have this. I wasn't sure if hMailServer is maybe adding in some other headers when it relays to the final destination?

mikedibella
Senior user
Senior user
Posts: 837
Joined: 2016-12-08 02:21

Re: How to log headers sent during SMTP client session?

Post by mikedibella » 2021-03-29 02:07

Maybe trap the delivery failures in a quarantine and use a scheduled task to delete them after a few days. Then you can review the entire header in the message file.

Code: Select all

sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
	set oFS = CreateObject("Scripting.FileSystemObject")
	on error resume next
	oFS.CopyFile oMessage.Filename, "C:\ProgramData\hMailServer\Quarantine\", True
	on error goto 0
end sub

beiley
New user
New user
Posts: 14
Joined: 2016-09-14 16:43
Location: AZ in the US
Contact:

Re: How to log headers sent during SMTP client session?

Post by beiley » 2021-03-29 20:58

Thanks, that does accomplish what I was after.

mikedibella
Senior user
Senior user
Posts: 837
Joined: 2016-12-08 02:21

Re: How to log headers sent during SMTP client session?

Post by mikedibella » 2021-03-29 21:09

Just a thought...if you want to preserve which recipient failed and why:

Code: Select all

sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
	oMessage.HeaderValue("X-hMailServer-Failure-Recipient") = sRecipient
	oMessage.HeaderValue("X-hMailServer-Failure-Reason") = sErrorMessage
	oMessage.Save
	set oFS = CreateObject("Scripting.FileSystemObject")
	on error resume next
	oFS.CopyFile oMessage.Filename, "C:\ProgramData\hMailServer\Quarantine\", True
	on error goto 0
end sub

beiley
New user
New user
Posts: 14
Joined: 2016-09-14 16:43
Location: AZ in the US
Contact:

Re: How to log headers sent during SMTP client session?

Post by beiley » 2021-03-29 21:16

Great idea, thanks again!

Post Reply