What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use PHPMailer as an authenticated SMTP client: connect to smtp.office365.com on port 587, negotiate STARTTLS, and authenticate with Microsoft Entra OAuth2 (XOAUTH2). The PHP application needs a licensed Microsoft 365 mailbox, outbound TCP 587, TLS 1.2 or 1.3, and SMTP AUTH enabled for that mailbox. Password-only SMTP authentication is a legacy path and may be blocked by tenant security policy.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
Choose the Microsoft 365 sending method first
Microsoft 365 offers several ways for an application on a LAMP server to submit mail. They are not interchangeable: each has different authentication, recipient, and infrastructure requirements.
As an Amazon Associate I earn from qualifying purchases.
| Method | Connection and authentication | Recipients and limits | When it fits a PHP application |
|---|---|---|---|
| Client SMTP submission | smtp.office365.com, port 587 (recommended) or 25, STARTTLS, mailbox authentication |
Internal and external recipients; Microsoft currently documents 10,000 recipients per day and 30 messages per minute for this method | The normal choice for a web application that can use one Microsoft 365 mailbox |
| SMTP relay | Tenant MX endpoint on port 25 with TLS; an inbound connector identifies the server by a certificate or static public IP | Useful when mailbox submission limits are insufficient; a licensed mailbox is not required | Controlled servers with connector administration and a static, unshared IP or certificate |
| Direct Send | Tenant MX endpoint on port 25; no licensed mailbox required | Microsoft 365 recipients only | Internal notifications, not Internet-facing transactional mail |
| High Volume Email or Azure Communication Services Email | Microsoft-managed high-volume services rather than ordinary mailbox submission | Workload, availability, quota, region, and pricing rules vary | Large internal workloads or internal-and-external delivery when mailbox submission is unsuitable |
For most PHP sites, start with client SMTP submission and OAuth2. Move to relay or a high-volume service only when the application’s volume, network design, or authentication policy makes mailbox submission a poor fit.
Prerequisites on the LAMP server and tenant
- A Microsoft 365 or Office 365 mailbox licensed for the tenant and designated for the application.
- A DNS-capable server that resolves
smtp.office365.com. Use the DNS name, not an IP address. - Outbound TCP port 587 allowed by the Linux firewall, cloud provider, hosting company, and any egress security group. Port 25 is an alternative for client submission but is commonly restricted by hosting providers.
- PHP with the OpenSSL extension and support for TLS 1.2 or TLS 1.3.
- SMTP AUTH enabled for the selected mailbox and not disabled by a tenant policy or Microsoft Entra Security Defaults.
- An Entra application registration and OAuth credentials if you use the recommended Modern Authentication path.
- A separate sender mailbox or an explicit Send As grant when the visible From address is different from the account used to authenticate.
Microsoft states that organizations created after January 2020 have SMTP AUTH disabled by default in many cases. Check the mailbox and tenant policy before diagnosing PHP code; a perfectly configured client still fails when the service refuses SMTP AUTH.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Install PHPMailer with Composer
PHP’s built-in mail() function usually hands a message to a local mail server, commonly through a sendmail binary on Linux. It does not itself provide a Microsoft 365 SMTP connection. PHPMailer gives the application an SMTP transport, TLS handling, authentication mechanisms, and message construction in one maintained package.
From the application directory, run:
composer require phpmailer/phpmailer
Load Composer’s autoloader in the web application:
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match<?php
require __DIR__ . '/vendor/autoload.php';
use PHPMailerPHPMailerException;
use PHPMailerPHPMailerPHPMailer;
Keep vendor/ and the lock file under your deployment process. Do not copy a PHPMailer source tree manually when Composer can manage updates and dependencies consistently.
Configure Microsoft Entra OAuth2 for SMTP
OAuth2 avoids placing a mailbox password in the PHP application and is the authentication model Microsoft recommends for current tenants. The flow has three stages: register an application, obtain a token that is allowed to send through SMTP, and give PHPMailer an OAuth provider that can refresh tokens.
1. Register the application
- In the Microsoft Entra admin center, create an application registration for the web application or its mail-sending component.
- Record the application’s client ID and tenant information. Keep any client secret in the server’s secret store or environment, never in a repository.
- Configure the redirect or consent details required by the OAuth flow selected for your application. The exact screen and consent requirements depend on whether a user or a service process authorizes the mailbox.
2. Grant the SMTP permission
Request the SMTP.Send permission scope https://outlook.office.com/SMTP.Send. Obtain administrator consent when the tenant requires it. Your token must be issued for the mailbox that will authenticate to SMTP; a token for an unrelated API or account will not authorize the SMTP session.
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
3. Obtain and protect tokens
Use the Entra OAuth flow appropriate to your application to obtain an access token and, where required, a refresh token. Store refresh tokens and client secrets outside the document root with permissions that prevent the web server’s unrelated users from reading them. Never commit them to Git, print them in an exception page, or include them in PHPMailer debug logs.
4. Give PHPMailer an OAuth provider
PHPMailer’s Azure example follows this pattern. The provider object must implement the OAuth2 client behavior needed to acquire and refresh the token; the exact provider package and callback setup depend on your chosen Entra flow.
<?php
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerOAuth;
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->Port = 587;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->SMTPAuth = true;
$mail->AuthType = 'XOAUTH2';
$provider = /* an Entra OAuth provider configured for your tenant */;
$mail->setOAuth(new OAuth([
'provider' => $provider,
'clientId' => getenv('M365_CLIENT_ID'),
'clientSecret' => getenv('M365_CLIENT_SECRET'),
'refreshToken' => getenv('M365_REFRESH_TOKEN'),
'userName' => getenv('M365_SMTP_USER'),
]));
The authenticated username is the mailbox address. Set the From address to that same mailbox unless an administrator has granted Send As permission for another address.
Build a complete SMTP send in PHP
The following example keeps credentials in environment variables, uses STARTTLS on the normal submission port, and sends one HTML message with a plain-text alternative.
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use PHPMailerPHPMailerException;
use PHPMailerPHPMailerOAuth;
use PHPMailerPHPMailerPHPMailer;
try {
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->Port = 587;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->SMTPAuth = true;
$mail->AuthType = 'XOAUTH2';
$provider = /* configure your Microsoft Entra OAuth provider here */;
$mail->setOAuth(new OAuth([
'provider' => $provider,
'clientId' => getenv('M365_CLIENT_ID'),
'clientSecret' => getenv('M365_CLIENT_SECRET'),
'refreshToken' => getenv('M365_REFRESH_TOKEN'),
'userName' => getenv('M365_SMTP_USER'),
]));
$sender = getenv('M365_SMTP_USER');
$mail->setFrom($sender, 'Site notifications');
$mail->addAddress('[email protected]');
$mail->Subject = 'Account notification';
$mail->isHTML(true);
$mail->Body = '<p>Your requested notification is ready.</p>';
$mail->AltBody = 'Your requested notification is ready.';
$mail->send();
} catch (Exception $e) {
error_log('Mail delivery failed: ' . $e->getMessage());
http_response_code(500);
}
Replace the provider construction and recipient with values managed by your application. Do not send the exception text to a browser in production: it can disclose server details, SMTP responses, or configuration.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
When a password-based example fails
Older tutorials often set SMTPAuth = true, assign a mailbox password, and use ordinary authentication. That approach is increasingly unavailable. Microsoft recommends Modern Authentication, and Basic authentication is incompatible with Microsoft Entra Security Defaults. If a legacy integration must use a password, an administrator has to confirm that SMTP AUTH is enabled for the mailbox and permitted by tenant policy; enabling it may conflict with the organization’s security requirements.
Do not “fix” an authentication error by disabling Security Defaults or weakening conditional-access controls without an explicit security review. Migrating the application to XOAUTH2 is the durable solution.
Verify TLS and network access from Linux
Check DNS
getent hosts smtp.office365.com
# or
dig +short smtp.office365.com
The command should return an address. A DNS failure means the PHP process cannot discover the SMTP service; investigate the server resolver and outbound DNS policy before changing PHPMailer settings.
Check the submission port and STARTTLS
openssl s_client -starttls smtp -connect smtp.office365.com:587 -crlf
A successful connection shows a TCP session followed by a TLS handshake and an SMTP service banner. Close the test with QUIT. If the command times out, the host firewall, provider egress policy, or network security group is blocking port 587. If OpenSSL is missing or cannot negotiate TLS 1.2/1.3, install or update the server’s OpenSSL/PHP packages rather than downgrading encryption.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsCheck PHP’s OpenSSL extension
php -m | grep -i openssl
php -i | grep -i 'OpenSSL support'
CLI output does not always reflect the PHP-FPM or Apache module used by the website. Confirm the extension in the same runtime that executes the application.
Mailbox policy and sender permissions
Enable SMTP AUTH only where required
Verify SMTP AUTH for the designated mailbox and confirm that no tenant-level policy blocks it. A tenant can allow SMTP AUTH generally while disabling it for a particular mailbox, or the reverse. Security Defaults and other authentication policies can also reject password-based attempts even when the mailbox exists.
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
Match From to the OAuth user
Set From to the authenticated mailbox for the first test. If the application must send as another mailbox, grant the authenticating account Send As permission in Microsoft 365. Without that permission, Microsoft documents the non-delivery report: 5.7.60 SMTP; Client doesn't have permissions to send as this sender.
Changing only the display name does not grant permission. Test the exact SMTP address, including aliases and accepted domains, and allow time for an administrative permission change to propagate.
Free tools Windows power users keep installed
One-click scans. No signup required.
Client submission, relay, and Direct Send in practice
Use client submission for ordinary website mail
Client submission authenticates a mailbox and can deliver to internal and external recipients. It uses smtp.office365.com, STARTTLS, and port 587 (or port 25 when permitted). Microsoft documents saving submitted messages to Sent Items, which can help mailbox auditing. The published service limits are 10,000 recipients per day and 30 messages per minute; treat these as service limits, not a queueing strategy. A bursty application should queue jobs and pace delivery below the documented ceiling.
Use SMTP relay for a controlled sending host
Relay uses the tenant’s MX endpoint on port 25 and an inbound connector. The connector can identify the source with a certificate or a static public IP address. A licensed mailbox is not required, but connector configuration and a static, unshared public IP or certificate are. This is appropriate for a fixed server under your control, not a PHP host whose egress address changes unexpectedly.
Use Direct Send only for Microsoft 365 recipients
Direct Send also uses the tenant MX endpoint and port 25 and does not require a licensed mailbox. It is restricted to Microsoft 365 recipients, so it cannot serve ordinary Internet-facing transactional mail. Do not select it merely because it avoids OAuth; its recipient restriction is fundamental.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Escalate high-volume workloads
Microsoft identifies High Volume Email for internal-recipient workloads and Azure Communication Services Email for internal and external recipients when client submission is not suitable. Availability, quotas, pricing, and regional support vary by tenant and region. Verify those current service terms before committing the application architecture.
Recommended Free Tools
Diagnose the common failure modes
| Symptom | Likely cause | Action |
|---|---|---|
| Connection timeout or “could not connect” | Outbound 587 blocked, DNS failure, or provider port restriction | Run getent hosts and openssl s_client from the LAMP host; ask the hosting provider to allow outbound TCP 587. |
| TLS handshake error | OpenSSL extension missing, old TLS stack, or STARTTLS misconfigured | Confirm PHP OpenSSL in the web runtime and TLS 1.2/1.3 support; use ENCRYPTION_STARTTLS with port 587. |
| Authentication rejected | SMTP AUTH disabled, token lacks SMTP.Send, wrong tenant, expired refresh token, or Security Defaults blocking Basic auth | Check mailbox policy, request https://outlook.office.com/SMTP.Send, renew the OAuth grant, and use XOAUTH2 rather than a password. |
| 5.7.60 sender permission error | From address differs from the authenticated mailbox without Send As | Make From equal to the OAuth user or grant explicit Send As permission. |
| Mail accepted but not delivered externally | Recipient filtering, domain reputation, content policy, or use of Direct Send for an external recipient | Confirm the chosen method supports external recipients, inspect Microsoft 365 message trace, and configure SPF, DKIM, and DMARC for the sending domain. |
| Works in CLI but fails through the website | Different PHP-FPM/Apache configuration, environment variables, certificate store, or filesystem permissions | Compare the web runtime’s PHP modules and environment; do not assume CLI settings apply to the web process. |
Use PHPMailer diagnostics safely
During a controlled diagnosis, enable SMTP server debugging temporarily:
$mail->SMTPDebug = 2;
Send the output only to a protected administrator log while reproducing one failure. Disable it immediately afterward. PHPMailer debug output can contain SMTP responses and identifying information; never log passwords, client secrets, access tokens, or refresh tokens. A production application should log a correlation ID and a sanitized error category, not the complete SMTP conversation.
Production design and security checklist
- Keep the client ID, client secret, refresh token, and mailbox address in environment variables or a dedicated secret manager outside the web root.
- Use a dedicated mailbox with the smallest practical permissions and a clear retention policy.
- Keep the authenticated mailbox and From address identical unless Send As has been approved and tested.
- Queue mail instead of blocking a customer-facing HTTP request while SMTP connects. Apply retries with backoff for transient failures and stop retrying permanent recipient or authentication errors.
- Throttle submission so the application remains below Microsoft’s 30-messages-per-minute client-submission limit and monitor the 10,000-recipient daily limit.
- Configure SPF, DKIM, and DMARC for the sending domain. These controls protect domain identity but do not replace SMTP authentication.
- Restrict administrative access to the server, rotate secrets, and revoke the Entra grant when the application is retired.
- Use HTML and plain-text alternatives, validate recipient input, and avoid placing untrusted content directly into message headers.
- Disable verbose PHPMailer debugging after diagnosis and alert on repeated authentication, TLS, or quota failures.
A deployment sequence that minimizes surprises
- Create or select the licensed Microsoft 365 mailbox and decide whether all mail will use that address.
- Confirm SMTP AUTH policy, Microsoft Entra Security Defaults, and any conditional-access rules for the mailbox.
- Register the Entra application and obtain consent for
https://outlook.office.com/SMTP.Send. - Install PHPMailer with Composer and deploy the lock file.
- Set the SMTP host, port 587, STARTTLS, SMTP authentication, and XOAUTH2 in a non-production environment.
- Store OAuth secrets outside source control and verify that the PHP web runtime can read them.
- Run DNS, port, TLS, and OpenSSL checks from the actual LAMP host.
- Send a test message with From equal to the authenticated mailbox, first to an internal address and then to an authorized external test address.
- Only after successful tests, add queueing, retry rules, monitoring, and any alternate sender identities.
Final decision
For a typical PHP application on Linux, the reliable baseline is PHPMailer, smtp.office365.com, port 587, STARTTLS, and OAuth2/XOAUTH2 through Microsoft Entra. The mailbox must be licensed, SMTP AUTH must be allowed, TLS 1.2 or 1.3 and outbound connectivity must work, and the From address must be authorized. If those constraints do not fit the workload, design for connector-based relay, restricted Direct Send, or an approved high-volume email service instead of forcing mailbox SMTP beyond its policy and limits.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




