[英]ms graph php sdk set from name when sending email
處理“發送和電子郵件”示例:
https://github.com/microsoftgraph/msgraph-sdk-php/wiki/Example-calls#send-an-email
我正在嘗試在已發送電子郵件的標題中設置電子郵件的“來自名稱”,以顯示“TEST”而不是與我的OWA帳戶關聯的名稱。
$graph = new Graph();
$graph->setAccessToken(access_token);
$mailBody = array( "Message" => array(
"subject" => $subject . ' ' . $from_name,
"body" => array(
"contentType" => "html",
"content" => $body
),
"sender" => array(
"emailAddress" => array(
"name" => "TEST",
"address" => $from_user->email
)
),
"from" => array(
"emailAddress" => array(
"name" => 'TEST',
"address" => $from_user->email
)
),
"toRecipients" => array(
array(
"emailAddress" => array(
"name" => $to_user->name,
"address" => $to_user->email
)
)
)
)
);
$response = $graph->createRequest("POST", "/me/sendMail")
->attachBody($mailBody)
->execute();
但是郵件頭總是具有來自我的OWA(outlook)帳戶的名稱。
AFAIK不支持通過senMail
端點覆蓋emailAddress
資源的 name
屬性。
但 Microsoft Graph支持允許用戶發送看似從其他用戶,通訊組列表,組,資源或共享郵箱發送的郵件的功能( 官方文檔 )
兩個郵箱權限會影響郵件的發送方式:
下面將介紹如何從名為Finance Department
組發送郵件
POST https://graph.microsoft.com/v1.0/me/sendMail
{
"message": {
"subject": "Finance results",
"body": {
"contentType": "text",
"content": "Some finance results goes here..."
},
"toRecipients": [
{
"emailAddress": {
"address": "mary@contoso.onmicrosoft.com"
}
}
],
"from": {
"emailAddress": {
"address": "financedeplist@contoso.onmicrosoft.com"
}
}
}
}
當前用戶: Jon Doe (jdoe@contoso.onmicrosoft.com)
選項1.代表發送
選項2.發送為
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.