You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useDa\Mailer\Queue\MailQueue;
useDa\Mailer\Queue\Backend\Redis\RedisQueueStoreAdapter;
useDa\Mailer\Queue\Backend\Redis\RedisQueueStoreConnection;
$conn = newRedisQueueStoreConnection([
'host' => 'localhost',
'port' => 9367,
]);
$adapter = newRedisQueueStoreAdapter($conn);
$queue = newMailQueue($adapter);
if (($job = $queue->dequeue()) !== null) {
// ... do something with received job// ... send it using `mail()` function for example$job->markAsCompleted();
$queue->ack($job);
}
Send email job with mail() function
useDa\Mailer\Mailer;
useDa\Mailer\Model\MailMessage;
useDa\Mailer\Transport\MailTransport;
$transport = newMailTransport();
$mailer = newMailer($transport);
$mailJob = /* ... get mail job here ... */;
$status = null;
try {
$status = $mailer->send(
newMailMessage(json_decode($mailJob->getMessage(), true))
);
} catch(Exception$e) {
// log exception;
}
if (is_null($status)) {
// ... cannot send email/* ... ack here with job not completed - will be set for later processing ... */
} else {
$mailJob->markAsCompleted();
/* ... ack here with job completed - will be ack on the queue backend storage ... */
}