OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
reader
/
aws-ses
/
vendor
/
phpmailer
/
phpmailer
/
examples
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/19/2025 10:07:13 AM
rwxr-xr-x
📄
DKIM_gen_keys.phps
3.32 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
DKIM_sign.phps
1.77 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
README.md
8 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
azure_xoauth2.phps
4.08 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
callback.phps
2.31 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
contactform-ajax.phps
5.14 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
contactform.phps
3.61 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
contents.html
585 bytes
03/03/2025 08:33:27 AM
rw-r--r--
📄
contentsutf8.html
1.15 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
exceptions.phps
1.66 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
extending.phps
2.63 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
gmail.phps
3.76 KB
03/03/2025 08:33:27 AM
rw-r--r--
📄
gmail_xoauth.phps
3.91 KB
03/03/2025 08:33:27 AM
rw-r--r--
📁
images
-
03/03/2025 08:39:14 AM
rwxr-xr-x
📄
mail.phps
1.15 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
mailing_list.phps
3.21 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
pop_before_smtp.phps
2.43 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
send_file_upload.phps
2.08 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
send_multiple_file_upload.phps
2.04 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
sendmail.phps
1.22 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
sendoauth2.phps
4.57 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
simple_contact_form.phps
3.91 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
smime_signed_mail.phps
4.28 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
smtp.phps
2.25 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
smtp_check.phps
2.07 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
smtp_low_memory.phps
4.93 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
smtp_no_auth.phps
1.87 KB
03/03/2025 08:33:28 AM
rw-r--r--
📄
ssl_options.phps
2.36 KB
03/03/2025 08:33:28 AM
rw-r--r--
Editing: sendoauth2.phps
Close
<?php /** * This example uses the SendOauth2 wrapper to support OAuth2 (and Basic) authentication for both Microsoft * 365 Exchange email and Google Gmail. * Client secrets and X.509 certificates are supported for Exchange. Client secrets are supported for Gmail. * Authorization_code grant flow and client_credentials (i.e. application) grant flow for SMTP are supported for * Exchange. Authorization_code grant flow is supported for Gmail. * Appropriate scopes (client permissions) and 'provider' overrides are added automatically. * * Install with Composer from the decomplexity/SendOauth2 repo. * * SendOauth2 can be also be invoked using less (or even no) arguments - see the repo for details. * * Needs PHPMailer >=6.6.0 that added support for oauthTokenProvider * * (The next release [V4] of the wrapper will replace TheLeague's Google provider by Google's own GoogleOauthClient; * this will provide support for Google's version of client credentials (Service Accounts) and client certificates) */ //Import SendOauth2B class into the global namespace use decomplexity\SendOauth2\SendOauth2B; //Import PHPMailer classes into the global namespace //These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; //Load Composer's autoloader require 'vendor/autoload.php'; //Create an instance; passing `true` enables exceptions $mail = new PHPMailer(true); try { //Server settings $mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->isSMTP(); //Send using SMTP $mail->Host = 'smtp.office365.com'; //Set the SMTP server (smtp.gmail.com for Gmail) $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = 'user@example.com'; //SMTP username $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable implicit TLS encryption $mail->Port = 465; //TCP port to connect to $mail->AuthType = 'XOAUTH2'; // Set AuthType to use XOAUTH2 //Sender and recipients $mail->setFrom('from@example.com', 'Mailer'); // 'Header' From address with optional sender name $mail->addAddress('joe@example.net', 'Joe User'); //Add a recipient //Authentication $oauthTokenProvider = new SendOauth2B( ['mail' => $mail, // PHPMailer instance 'tenant' => 'long string', // tenant GUID or domain name. Null for Gmail 'clientId' => 'long string', 'clientSecret' => 'long string', // or null if using a certificate 'clientCertificatePrivateKey' => 'extremely long string', // or null if using a clientSecret 'clientCertificateThumbprint' => 'long string', // or null if using a clientSecret 'serviceProvider' => 'Microsoft', // or Google 'authTypeSetting' => $mail->AuthType, // is set above - or insert here as 'XOAUTH2' 'mailSMTPAddress' => 'me@mydomain.com', // Envelope/mailFrom/reverse-path From address 'hostedDomain' => 'mydomain.com', // Google only (and optional) 'refreshToken' => 'very long string', 'grantTypeValue' => 'authorization_code', // or 'client_credentials' (Microsoft only) ] ); /** * If an argument (above) has a null value, the argument can be omitted altogether. * ClientCertificatePrivateKey should include the -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- */ $mail->setOAuth($oauthTokenProvider); //Pass OAuthTokenProvider to PHPMailer //Content $mail->isHTML(true); //Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body <b>in bold!</b>'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; }