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
$connection = new \Da\Mailer\Queue\Backend\RabbitMq\RabbitMqQueueConnection([
'host' => 'localhost',
'port' => 5672,
'user' => 'guest',
'password' => 'guest'
]);
$adapter = new \Da\Mailer\Queue\Backend\RabbitMq\RabbitMqQueueStoreAdapter($connection);
$queue = new \Da\Mailer\Queue\MailQueue($adapter);
$job = $queue->dequeue();
if ($job !== null) {
// perform some action with the job e.g send email$job->markAsCompleted();
$queue->ack($job);
}
Send email with the mail() function
$transport = new \Da\Mailer\Transport\SmtpTransport($host, $user, $options);
$mailer = new \Da\Mailer\Model\MailMessage($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 ... */
}