[API Proposal]: Customized date formatting for SmtpClient #110361
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.Net
needs-further-triage
Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone
Background and motivation
I've had a long term issue with the built in mail app on my phone(Xiaomi) for a number of years. Any email sent via .NET shows 12/31/1969 for the date. I'm inbetween projects for a few hours this morning and it finally bugged me enough to look into it. So I turned on debug logging on our mail server and captured a few hundred emails from various sources this morning and directly ran some sets with .NET Framework 4.8 and .NET 9.
The likely cause of the issue with Xiaomi's mail app is the format used by the date. I don't think they understood RFC822 where the day of the week is an optional field([]).
Out of the 128 emails I parsed in the logs, the only one not sending the DOW is .NET. Is there some flag I'm missing?
For example, I sent an email to my Outlook email from a .NET 9 WinForm app:
Date: 3 Dec 2024 09:26:24 -0600
I then replied to that email from Outlook.com and got back
Date: Tue, 3 Dec 2024 15:36:32 +0000
I recognize I don't have an issue viewing the non-DOW formatted date with Thunderbird, Outlook client, Outlook.com, Yahoo mail, and GMail. I recognize 128 emails is a pretty small sampling, but if everyone else is doing it, could it be an option to turn on for additional compatibility?
API Proposal
enum SmtpDateFormatting { Standard,Full };
public DateFormatting=SmtpDateFormatting.Standard;
string tz=date.ToString("zzz").Replace(":","");
if(DateFormatting==SmtpDateFormatting.Full)
return date.ToString("ddd, d MMM yyyy HH:mm:ss ")+tz;
else
return date.ToString("d MMM yyyy HH:mm:ss ")+tz;
API Usage
SmtpClient.DateFormatting=SmtpDateFormatting.Full;
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: