Laravel, access smtp via modern authentication

FFor 1 Reputation point

Hello,I have an application that sends mail with a customer's microsoft365 account.
Up to now SMTP authentication has been used, now customer wants to switch to modern Authentication.
A new application on azure has been created, and I have been provided with Tenant ID,
Application ID and Secret.

From what I understand in order to keep logged in I need a refresh token, I have followed diffrent guides but I'm not able to generate it.

is it possible to generate a token for a SMTP resource?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,336 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 39,736 Reputation points

    Hi @FFor

    You can try using auth code flow to get an access token and a refresh token.

    1.Run the URL in the browser to get the authorization code.{tenant id}/oauth2/v2.0/authorize?  
    client_id={client id}  
    &redirect_uri={redirect url}  
    &scope= offline_access  


    2.Use the authorization code to redeem an access token and a refresh token.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.