webprofil / wp-mailqueue
Package info
github.com/Gernott/wp_mailqueue
Type:typo3-cms-extension
pkg:composer/webprofil/wp-mailqueue
Requires
- typo3/cms-core: ^13.4
Replaces
- typo3-ter/wp-mailqueue: 3.0.0
README
This extension offers the possibility to send mails from your extbase extension via a Mailqueue. Usually, when you send mails via Extbase, the Mails are sent immediately. This can run into problems with your mailprovider, when he allows only a specific amount of mails per time. This extension helps you with this problem.
Upgrade from v2,x to v3.x
Breaking changes:
- Run both upgrade wizards in your Installtool to migrate to the new database fields.
- Adjust your code to the new methods. E.g., setRecipient() -> setRecipients()
How does it work
Instead of sending Mails like this:
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('john.doe@example.org', 'John Doe')) ->to( new Address('receiver@example.com', 'Max Mustermann'), new Address('other@example.net') ) ->subject('Your subject') ->text('Here is the message itself') ->send() ;
Use our Class/Method:
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('sender@example.com', 'Sendername')) ->to( new Address('receiver@example.com', 'Max Mustermann'), new Address('other@example.net') ) ->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('receiver@example.com', 'Max Mustermann'), new Address('other@example.net') ) ->bcc( new Address('receiver@example.com', 'Max Mustermann'), new Address('other@example.net') ) ->attachFromPath( '1:/user_upload/file1.pdf', '1:/user_upload/file2.pdf' ) ->attachFromFileReference( $fileReference, $anotherFileReference ) ; // Add Mail to Mailqueue MailqueueUtility::addToMailqueue($mail);
Full control in the Backend
Take a look into the Backend module of wp_mailqueue. It is self explained. Here you can have a look to the queued and sent mails. You can delete queued mails.
Scheduler Tasks for sending
Add and activate the Scheduler Task to activate the Mailsending from the mailqueue: Execute console commands mailqueue:run