-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with sending emails #3035
Comments
This looks like an auth issue. See if you get anything useful if you set debug to Also, unless you just did it for posting here, |
It looks as if either:
i.e. unless some debug information is missing, it doesn't look as if things have got a far as your presenting an access token to MSFT's SMTP gateway for authentication So it is worth looking at the AAD sign-in logs to see if there is anything of relevance there. After you have signed in once, the MSFT authorization-code server should think that it has already passed you an authorization code when it calls the redirectURI (the code is suffixed to the URI). Then also: |
One simple thing that could be at work – if you don't set |
I am currently testing the script on localhost which is why its showing EHLO localhost. It worked before without any issues but regardless it doesn't work on the live web server. Here is what I get when using DEBUG_LOWLEVEL: 2024-03-13 15:28:57 Connection: opening to smtp.office365.com:587, timeout=300, options=array() |
Here is my code with redacted info: $mail = new PHPMailer(true); try {
} catch (Exception $e) { |
Thanks, that output is useful. Looking at the output, we can see you're getting the |
My question is how could the null === $OAuth be true now if it wasn't on Friday? The code hasn't been touched in the last month. The only thing I can think of is the refresh token or secret token expiring but I just made new ones and still having the same issue. So I just checked and the Azure AD is saying that the refresh token is expired due to inactivity. The token was issued on {issueDate} and was inactive for {time}. |
Having expiry and inactivity on the refresh token seems a bit unsporting! So is your issue now solved? |
Lol yeah the issue is fixed now I just had to generate a new refresh token. One question when do the refresh tokens expire? This one was only valid for about 2 months |
Generous but safety-conscious Mr MSFT gives refresh tokens 90 days maximum life (less for single-page apps). |
Glad it's fixed. Refresh expiry depends on the service; I expect it will be documented somewhere, but you'll need to find it. |
@decomplexity @Synchro official doc is here https://learn.microsoft.com/en-us/entra/identity-platform/refresh-tokens.
So very likely there is the need to store somewhere the new refresh token issued on every use, instead of using just the "first" one (that very likely is put in a .ENV conf). |
Storage of the new refresh token is already done when using the 'full' version of the wrapper (i.e. when using SendOauth2A instead of PHPMailer's OAuthTokenProvider interface). The new refresh token is automatically written to the SendOAuth2 interchange file. |
I had phpmailer setup for automatic reminders that get sent out every week and everything has been working fine for the last 2 months but today the email's aren't getting sent out anymore. I'm using Azure AD and my token expires in 2025. I also re did the oauth and got all new tokens but that didn't seem to help. The error log when using $mail->SMTPDebug = SMTP::DEBUG_SERVER; doesn't show much.
2024-03-13 13:35:06 SERVER -> CLIENT: 220 YQXPR0101CA0058.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 13 Mar 2024 13:35:04 +0000
2024-03-13 13:35:06 CLIENT -> SERVER: EHLO localhost
2024-03-13 13:35:06 SERVER -> CLIENT: 250-YQXPR0101CA0058.outlook.office365.com Hello [xxx.xxx.xxx.xxx]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8
2024-03-13 13:35:06 CLIENT -> SERVER: STARTTLS
2024-03-13 13:35:06 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2024-03-13 13:35:06 CLIENT -> SERVER: EHLO localhost
2024-03-13 13:35:06 SERVER -> CLIENT: 250-YQXPR0101CA0058.outlook.office365.com Hello [xxx.xxx.xxx.xxx]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-AUTH LOGIN XOAUTH2250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8
2024-03-13 13:35:06 CLIENT -> SERVER: QUIT
2024-03-13 13:35:07 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
The text was updated successfully, but these errors were encountered: