PHP code example of suny-upstate-cwt / phpmailerqol
1. Go to this page and download the library: Download suny-upstate-cwt/phpmailerqol library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
suny-upstate-cwt / phpmailerqol example snippets
// Import PHPMailerQOL class into the global namespace
// These must be at the top of your script, not inside a function
use SUNYUpstateCWT\PHPMailerQOL\PHPMailerQOL;
// Load Composer's autoloader (created by composer, not included with PHPMailerQOL)
n validation is not performed by PHPMailerQOL
$mail->setDefaultAddressDomain('example.com');
// Clear default domain
// Pass in ANY "empty" or non-scalar value
// $mail->setDefaultAddressDomain('');
// $mail->setDefaultAddressDomain(null);
// $mail->setDefaultAddressDomain([]);
// Set FROM
$mail->setFrom('no-reply', 'no-reply'); // Set From: no-reply <[email protected]>
// Add addresses
$mail->addAddress([ // Add TOs:
'co-worker1'=>'John', // John <[email protected]>
'co-worker2'=>'Jim' // Jim <[email protected]>
]);
// Add addresses and vanity names in separate arrays
$mail->addAddress([ // Add TOs:
['email1', 'email2'], // email1 <[email protected]>
['Email1 Name', 'Email2 Name'], // email2 <[email protected]>
]);
// Remove previously added TOs and set anew
$mail->setTO([ // Set TO:
'co-worker3', // [email protected]
'co-worker4', // [email protected]
'[email protected]' // [email protected]
]);
// Add a CC
$mail->addCC('Some Name <address>'); // This will FAIL; domain must be
$mail = new PHPMailerQOL(true);
$mail->setDefaultAddressDomain('example.com');
$mail->addAddress([
'co-worker1'=>'John',
'co-worker2'=>'Jim',
'co-worker4'=>'Jack'
]);
$mail->addBCC('co-worker3');
$mail->removeAddress('co-worker1'); // Bye-bye co-worker1 from TOs
$mail->removeRecipient(['co-worker2','[email protected]']); // Bye-bye co-worker2 and 3 from TOs, CCs, and BCCs
$mail->Subject = 'My subject';
$mail->Body = 'Some body';
$mail->send(); // Email sent to just [email protected]
$mail = new PHPMailerQOL(true);
$mail->setDefaultAddressDomain('example.com');
$mail->Subject = 'My subject';
$mail->Body = 'Some body';
// Everyone should get an individual email instead of cramming everyone into the BCC
foreach( $list_of_emails as $email ) {
$mail->setTO($email);
$mail->send();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.