microsoftgraph / microsoftgraph/msgraph-sdk-java

Sending SMIME messages with sendMail endpoint is broken.

Đang mở
#2,544 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

status:waiting-for-triage type:bug
Ngôn ngữ chính
Java
Star
444
Fork
154
Merge trung bình
18 giờ 28 phút
Pull request đã merge (30 ngày)
4

Mô tả

Describe the bug

Hello,

We are using Microsoft Graph Java SDK to send encrypted SMIME Messages.
We are already encrypting the content and provide a full MIME document to endpoint:
https://graph.microsoft.com/v1.0/me/sendMail

For example our MIME Message looks like this (saved on content variable):

Date: Tue, 10 Feb 2026 11:24:45 +0000 (UTC)
From: HenriettaM@xyz.onmicrosoft.com
To: xxx-test@gmx.de
Message-ID: <....>
Subject: Test2
MIME-Version: 1.0
Content-Type: application/pkcs7-mime; name="smime.p7m"; smime-type=authEnveloped-data
Content-Transfer-Encoding: base64

MIAGCyqGSIb3DQEJEAEXoIAwgAIBADGCAdswggHXAgEAMIGPMHcxCzAJBgNVBAYTAkRFMQwwCgYD
...

We are using the following code snipplet to send the Email:

initializeGraphClient();
String encoded = Base64.getEncoder().encodeToString(content.getBytes());

RequestInformation requestInfo = new RequestInformation();
requestInfo.httpMethod = HttpMethod.POST;
requestInfo.urlTemplate = "{+baseurl}/users/{+email}/sendMail";
requestInfo.pathParameters = new HashMap<>();
requestInfo.pathParameters.put("baseurl", "https://graph.microsoft.com/v1.0");
requestInfo.pathParameters.put("email", config.getMailbox());
requestInfo.headers.put("Content-Type", Set.of("text/plain"));
requestInfo.setContentFromScalar(client.getRequestAdapter(), "text/plain", encoded);

HashMap<String, ParsableFactory< ? extends Parsable>> errorMapping = new HashMap<>();
errorMapping.put("4XX", ODataError::createFromDiscriminatorValue);
errorMapping.put("5XX", ODataError::createFromDiscriminatorValue);

client.getRequestAdapter().sendPrimitive(requestInfo, errorMapping, Void.class);

However our SMIME content is converted into an attachment and send as an attachment packed into a multipart/mixed structure by sending the Email.

Here is what we get on the reciever side:

Content-Type: multipart/mixed;
	boundary="_002_155174533371770722695547_"
MIME-Version: 1.0

--_002_155174533371770722695547_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

--_002_155174533371770722695547_
Content-Type: application/pkcs7-mime; name="smime.p7m"
Content-Description: smime.p7m
Content-Disposition: attachment; filename="smime.p7m"; size=4483;
	creation-date="Tue, 10 Feb 2026 11:33:38 GMT";
	modification-date="Tue, 10 Feb 2026 11:33:38 GMT"
Content-ID: <C06558A1F17AA04CAE95309F8C325E89@namprd19.prod.outlook.com>
Content-Transfer-Encoding: base64

MIAGCyqGSIb3DQEJEAEXoIAwgAIBADGCAdswggHXAgEAMIGPMHcxCzAJBgNVBAYTAkRFMQwwCgYD

Can you fix sending a SMIME by using this sendMail endpoint or is there any alternative ways for sending SMIME with Graph API?
We basically followed the Example 4 in this documentation page:

https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=http#example-4-send-a-new-message-using-mime-format

Expected behavior

Sending SMIME messages should work with the sendMail endpoint when Content-Type is provided as text/plain.

How to reproduce

See the code snipplet above for example code.
We can also provide a full SMIME example content if you want.

SDK Version

No response

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

No response

Configuration

No response

Other information

No response

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với ví dụ MIME của sendMail trong tài liệu Microsoft Graph được liên kết và tái hiện yêu cầu RequestInformation được nêu trong issue, bao gồm Content-Type và phần thân đã mã hóa của yêu cầu. So sánh yêu cầu này với thông báo multipart/mixed đã nhận để xác định hành vi thuộc về Java SDK hay endpoint Graph. Hoàn tất khi đã xác nhận bản sửa SDK, hoặc ghi lại được một giới hạn đã được tài liệu hóa của Graph cùng với một phương án thay thế được hỗ trợ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.