Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emailing XARF(content-type) #14

Open
NXTwoThou opened this issue Jun 28, 2024 · 4 comments
Open

Emailing XARF(content-type) #14

NXTwoThou opened this issue Jun 28, 2024 · 4 comments

Comments

@NXTwoThou
Copy link

I was trying to add XARF email reporting to my own software and haven't been able to figure out how to switch the MailMessage Content-Type from "multipart/mixed" to "multipart/report; report-type=feedback-report". I came across yours and I'm not seeing it either. Are you doing it through another mechanism I'm not seeing or do whom you've reported to not care?

@Subtixx
Copy link
Contributor

Subtixx commented Jun 28, 2024

Actually no, we do not add this email header to the files. If it would, it would be in here

I read up on that quickly and the easiest way I think could be to just use:
message.Headers.Add("Content-Type", "multipart/report; report-type=abuse"); in combination with

AlternateView reportView = new AlternateView("report.txt", "text/plain");                                 

for the human-readable format.

@NXTwoThou
Copy link
Author

Thanks for the reply. I wasn't sure if I was missing something in your implementation. I guess you haven't had any problems sending reports? XARF via SMTP made it seem like it was important.

Unfortunately, Headers.Add doesn't do anything when it comes to Content-Type(it was the first thing I tried).

@Subtixx
Copy link
Contributor

Subtixx commented Jun 28, 2024

We didn't had problems no. But we only received replies from those companies however:

  • Amazon Web Services (confused about XARF.. Had to explain them what this report is about in 3-4 E-Mails..)
  • Hetzner (No problems, really chill and fast response that the cases will be looked into)
  • Netcup (No issues, again cases will be looked into)
  • MyLoc Managed IT (Had to explain what XARF is, after that no issues)

Hmm Do you use C# in your application?

EDIT:
Seems like other projects use the "Content-type" header with no issues?
https://github.com/mjl-/mox/blob/7e54280a9d9df32db894ff11b45fcaeb7c1d24da/dsn/dsn.go#L142

Maybe this is just an issue with C#/.NET/System.Net.Mail

This seems like it does support it under C#: https://github.com/jstedfast/MimeKit aka https://github.com/jstedfast/MailKit does support it.

Also to be honest, I wouldn't count on System.Net.Mail in 2024, rather use Mailkit for example.

@NXTwoThou
Copy link
Author

NXTwoThou commented Jun 28, 2024

The only group I'm having any issues reporting to right now is DigitalOcean. I'm getting dozens a day and using their reporting form is extremely annoying. They accept XARF. It's encouraging that you haven't had any issues reporting to others without the headers that are mentioned required in the format.

Yes, I'm using C#. That first link isn't C# so unfortunately, it's not relevant.
Likely is an issue with System.Net.Mail.
I'm gone ahead and added MailKit and the only thing I'm missing is the "report-type=feedback-report;" bit after multipart/report. Looking into it now.

Thanks a bunch!

EDIT:
All done. Easy pleasey. Just had to give up on System.Net.Mail. These chunks give me identical to what Abusix shows.

`
string userAgent = "BlockGenie/1.0";
MemoryStream memoryStreamFeedbackType = new MemoryStream(ASCIIEncoding.ASCII.GetBytes("Feedback-Type: xarf\nUser-Agent: " + userAgent + "\nVersion: 1"));

var multipartBody = new TextPart("plain") { Text = body };
var multipartFeedbackType = new MimePart("message", "feedback-report")
{
Content = new MimeContent(memoryStreamFeedbackType),
ContentDisposition = new ContentDisposition(ContentDisposition.Inline)
};
var multipartAttachmentXARF = new MimePart("application", "json")
{
Content = new MimeContent(memoryStreamXARF),
ContentDisposition = new ContentDisposition(ContentDisposition.Attachment),
ContentTransferEncoding = ContentEncoding.Base64,
FileName = "xarf.json"
};

var multipart = new Multipart("report; report-type=feedback-report");
multipart.Add(multipartBody);
multipart.Add(multipartFeedbackType);
multipart.Add(multipartAttachmentXARF);
message.Body = multipart;
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants