0

I am adding X-SMTPAPI header for sendgrid category. The header is getting added fine when I dispatch the job using dispatch_now but when I use dispatch only the header is not getting added.

Code for dispatching the job:

Route::get('send-test-email', function(){
    // ini_set("memory_limit", "2048M");
    $arr["fname"] = 'Testfirst';
    $arr["lname"] = 'Lastname';
    $arr["mail"] = 'testf1@mailinator.com';
    
    $emailJob = new SendEmail($arr);

    // dispatch_now($emailJob);
    dispatch($emailJob);
    die('ere');
});

Job:

$email = new CompleteMail($this->details);
Mail::mailer('noreply')
    ->to($this->details['mail'],$this->details['full_name'])
    ->send($email);

Mailable inside build():

$this->withSwiftMessage(function ($message) use ($header) {
    $message->getHeaders()->addTextHeader('X-SMTPAPI', '{"category": "EXAMPLE_CATEGORY"}');
});
dev_sk
  • 85
  • 1
  • 9

1 Answers1

0

Needed to clear the cache, restart the queue and running the specific queue solved the issue.

php artisan queue:work --queue=queuename
dev_sk
  • 85
  • 1
  • 9