Emails send using Microsoft Graph API are being rejected for spam

Greg Steckel 0 Reputation points
2024-10-22T21:10:49.4166667+00:00

I was originally using flask_mail to send emails from my website but when Microsoft started requiring further authentication I figured I would switch to use OAuth2 to send emails using a token. From there I bough a basic business account for 6$/Month and set up a graph app in my tenant. Now when I send emails with this tenant they are rejected for spam: "Remote server returned '550 5.7.708 Service unavailable. Access denied, traffic not accepted from this IP" When I send an email manually it goes through no problem. Other posts about this topic suggest a problem with the tenant's ip and to contact a Microsoft engineer but I current am not eligible for technical support. Anything helps, thanks.

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. hossein jalilian 10,825 Reputation points Volunteer Moderator
    2024-10-22T23:53:18.6433333+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    Ensure your app registration in Azure AD has the correct permissions(Mail.Send , Mail.Send.Shared) and check that admin consent has been granted for these permissions.

    Properly configuring Sender Policy Framework and DomainKeys Identified Mail can help improve email deliverability and enable and configure DKIM in Microsoft 365


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful

    0 comments No comments

  2. Rajat Vashistha-MSFT 1,690 Reputation points Microsoft External Staff
    2024-10-23T10:30:20.54+00:00

    Hello Greg Steckel,

    Thank you for reaching Microsoft Support.

    To fix this issue your Tenant needs to be added to a sending exclusion for 60 days to allow them to use blocked IPs.

    I would recommend you raise a support case with Microsoft Graph, a Support Engineer will be able to assist you better and the respective team will provide exclusion for your tenant. This is the only way to fix the issue.

    You can raise support ticket from New support request - Microsoft Entra admin center or https://admin.microsoft.com/#/support/requests.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.