Skip to content

400 Client Error: Bad Request Error Message: Resource not found for the segment 'sendMail'. #8

Open
@technqvi

Description

@technqvi

Hi

I try to setup up the package as your advice as a prior question.
this link #7

400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/sendMail | Error Message: Resource not found for the segment 'sendMail'.

I click to https://graph.microsoft.com/v1.0/sendMail in order to dig deeper into additional error

{"error":{"code":"InvalidAuthenticationToken","message":"Access token is empty.","innerError":{"date":"2022-11-24T13:45:25","request-id":"4b533efc-d806-4829-a506-ba03599ebd69","client-request-id":"4b533efc-d806-4829-a506-ba03599ebd69"}}}

image

Below are my code and configuration and package installation.

image

settings.py

EMAIL_BACKEND = 'django_o365mail.EmailBackend'
O365_MAIL_CLIENT_ID ='xxxxxxxxxxxxxxx'
O365_MAIL_CLIENT_SECRET ='yyyyzzzyyyyy'
O365_MAIL_TENANT_ID ='zzzzzzzzz'
O365_ACTUALLY_SEND_IN_DEBUG=True

views.py

from django.core.mail import BadHeaderError, send_mail
from django.http import HttpResponse
def send_mail_office365(request):
    try:
        send_mail(
            subject='SmartApp - Test Sending Email',
            message='Hi, ok',
            from_email='smartapp-service@xxxxxgroup.com',
            recipient_list=['Taned.Sa@xxxxx.com'])
    except BadHeaderError:
        return HttpResponse('Invalid header found.')
    return render(request,
                  'app/pm_doc_gen_pdf.html',
                  {})

The last picture is what the azure administrator of my company set up.
image

Thank you for your advice

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions