microsoftgraph / microsoftgraph/msgraph-sdk-java
Sending SMIME messages with sendMail endpoint is broken.
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 444
- 派生
- 154
- 平均合并
- 18 小时 28 分钟
- 30 天内合并 PR
- 4
描述
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:
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从链接的 Microsoft Graph 文档中的 sendMail MIME 示例开始,复现 issue 中所示的 RequestInformation 请求,包括其 Content-Type 和编码后的正文。将该请求与收到的 multipart/mixed 消息进行比较,以确定此行为属于 Java SDK 还是 Graph 终结点。完成标准是确认 SDK 修复,或记录 Graph 的限制以及受支持的替代方案。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100