通过Azure AD Graph API发送电子邮件作为电子邮件别名 [英] Send email thru Azure AD Graph API as email alias
问题描述
在Graph API资源管理器中,您可以发送带有端点的电子邮件
https://graph.microsoft.com/v1.0/me/sendMail
和
In the Graph API explorer, you can send an email with the endpoint
https://graph.microsoft.com/v1.0/me/sendMail
and a basic json payload of
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [
{
"emailAddress": {
"address": "user@domain.com"
}
}
],
"from":{
"emailAddress": {
"address": "smtp:my_alias@domain.com"
}
}
}
当我发送此请求时,它仍然以 user@domain.com
而不是我的电子邮件别名发送电子邮件.运行端点时,仍然可以在其中看到电子邮件别名
https://graph.microsoft.com/beta/me/
在代理地址下
我查看了文档,没有看到任何明确的示例作为电子邮件发送别名的选项.
When I send this request, it still sends the email as user@domain.com
instead of my email alias.
I can still see the email alias there when i run the endpoint
https://graph.microsoft.com/beta/me/
Under proxyAddresses
I've looked over the documentation and don't see any clear example of option to send the email as alias.
推荐答案
从共享库发送消息时,我们只能将 from
和 sender
属性设置为不同的值邮箱,共享日历或作为委托.在此处中查看详情>(请参见表单和发件人)和
We can only set from
and sender
properties to a different value when sending a message from a shared mailbox, for a shared calendar, or as a delegate. See details here (see form and sender) and Setting the from and sender properties. Sending email as alias is not mentioned and cannot work based on the test.
因此,不支持通过Microsoft Graph API作为别名发送电子邮件.
So it's not supported to send the email as alias via Microsoft Graph API.
from
和 sender
的值必须与使用的实际邮箱相对应.因此,将电子邮件作为别名发送的唯一方法是在O365管理中心将别名更改为主要电子邮件,然后发送电子邮件.
The value of from
and sender
must correspond to the actual mailbox used. So the only way to send email as alias is to change alias to primary email in O365 admin center and then send email.
作为一种解决方法,如果仅希望收件人认为您是从别名发送邮件,则可以为邮箱配置代理邮箱(将邮箱的 sendAs 权限分配给代理用户).委派的邮箱实际上是另一个邮箱,需要分配一个Exchange Online许可证.然后将 from
属性设置为对您的Microsoft Graph API中的邮箱具有 sendAs 权限的委派用户.查看详细信息这里.之后,当您发送电子邮件时,收件人将看到来自委托电子邮件的电子邮件.
As a workaround, if you just want recipients to think that you are sending from alias, you can configure a delegated mailbox for your mailbox (assign sendAs rights of the mailbox to a delegated user). Delegated mailbox is actually another mailbox and needs to be assigned an Exchange Online license. Then set the from
property to the delegated user who have sendAs rights for your mailbox in Microsoft Graph API. See details here. After that, when you send an email, the recipient will see it's from the delegated email.
关于如何在Exchange管理中心中分配 sendAs 权限,请参考
About how to assign sendAs rights in Exchange Admin Center, please refer to Use the EAC to assign permissions to individual mailboxes. It may take several hours to take effect.
POST https://graph.microsoft.com/beta/me/sendMail
{
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [{
"emailAddress": {
"address": "user@domain.com"
}
}
],
"from": {
"emailAddress": {
"address": "{delegated mailbox}"
}
}
}
}
这篇关于通过Azure AD Graph API发送电子邮件作为电子邮件别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!