Hi,
I have a problem with Azure email sending by graph API. Let me describe the current situation.
We created an app in Azure that is in mail-enabled security group and it's a member of the shared mailbox. This mailbox has the name e.g ******@mydomain.com
.
We have also granted Mail.Send permission in graph API with application
type and consent for that was approved.
This is pseudo code of our current email client implementation in node.js
class AzureEmailClient {
private mailClient: Client;
constructor() {
const credential = new ClientSecretCredential(TENANT_ID, CLIENT_ID, CLIENT_SECRET);
const authProvider = new TokenCredentialAuthenticationProvider(credential, {
scopes: ['https://graph.microsoft.com/.default']
});
this.mailClient = Client.initWithMiddleware({
debugLogging: true,
authProvider
});
}
sendEmail({ from, subject, to, body }: EmailProps) {
const message: Message = {
from: {
emailAddress: {
name: 'Dawid Budzich via MyApp',
address: '******@mydomain.com'
}
},
sender: {
emailAddress: {
address: '******@mydomain.com',
}
},
subject,
toRecipients: to,
body: {
content: body,
contentType: "html",
},
};
this.mailClient.api(`/users/******@mydomain.com/sendMail`).post({ message, saveToSentItems: 'false' });
}
}
As you can see we have in the message payload set emailAddress.name
. However, this attribute is not used by azure, so instead of
We got
Look at the from name on the second screen, it's just an email address translated into some readable string. From our POV users will put more trust to the message from first screen. So far we were using Amazon SES and in the email from SES the from name is properly set (FYI we are using a different domain for SES), right now we wanted to switch into Azure, but if we won't fix this issue, we will have to stay with using SES.
To summarize, we set the email sender name in the message payload, but it's not being used for some reason.
Thanks in advance for your comments.
Regards,
Dawid Budzich