PHP code example of webprofil / wp-mailqueue

1. Go to this page and download the library: Download webprofil/wp-mailqueue 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/ */

    

webprofil / wp-mailqueue example snippets


use Symfony\Component\Mime\Address;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;

$mail = GeneralUtility::makeInstance(MailMessage::class);
$mail
   ->from(new Address('[email protected]', 'John Doe'))
   ->to(
      new Address('[email protected]', 'Max Mustermann'),
      new Address('[email protected]')
   )
   ->subject('Your subject')
   ->text('Here is the message itself')
   ->send()
 ;

use Symfony\Component\Mime\Address;
use TYPO3\CMS\Core\Mail\FluidEmail;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use WEBprofil\WpMailqueue\Domain\Model\Mail;

// 1. Initialize the object
$mail = GeneralUtility::makeInstance(Mail::class);

// 2. Fill the object
$mail
    ->from(new Address('[email protected]', 'Sendername'))
    ->to(
        new Address('[email protected]', 'Max Mustermann'),
        new Address('[email protected]')
    )
    ->subject(LocalizationUtility::translate('subject', 'extensionName'))
    ->text('Here is the message itself')
    ->html('Here is the message itself in <b>HTML</b> format')
    ->format(FluidEmail::FORMAT_BOTH) // FluidEmail::FORMAT_PLAIN, FluidEmail::FORMAT_HTML
    ->cc(
        new Address('[email protected]', 'Max Mustermann'),
        new Address('[email protected]')
    )
    ->bcc(
        new Address('[email protected]', 'Max Mustermann'),
        new Address('[email protected]')
    )
    ->attachFromPath(
        '1:/user_upload/file1.pdf',
        '1:/user_upload/file2.pdf'
    )
    ->attachFromFileReference(
        $fileReference,
        $anotherFileReference
    )
;

// Add Mail to Mailqueue
MailqueueUtility::addToMailqueue($mail);