Some months ago, I wanted to know how it's possible to be sure that an email has been sent.
Hmmm ... the application can't know if an email has been sent successfully, it can only tell you that the job is executed successfully.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have queued emails which work... some of the time. After a few hours, the queued jobs are created, processed and marked as done, but there is no communication with the smtp server (microsoft exchange).
Some relevant code is below:
In the controller:
// $bcc = list of addresses
Mail::to('[email protected]')->bcc($bcc)->send(new NewPatientNotification("test", "email.newpatient"));
The mailable
class NewPatientNotification extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public function __construct(public string $subj, public string $viewName)
{
log_info("New Patient Notification Construct: sending email for ....");
}
public function build()
{
log_info("New Patient Notification Build");
return $this->subject($this->subj)->view($this->viewName);
}
}
The log (this one worked):
2025-03-20 07:14:00 App\Mail\NewPatientNotification ................ RUNNING
LOG: [user_id=0]App\Mail\NewPatientNotification@build(36): New Patient Notification Build:
2025-03-20 07:14:02 App\Mail\NewPatientNotification ................ 2s DONE
The log (this one didn't work):
2025-04-03 15:08:34 App\Mail\NewPatientNotification ................ RUNNING
LOG: [user_id=0]App\Mail\NewPatientNotification@build(36): New Patient Notification Build:
2025-04-03 15:08:34 App\Mail\NewPatientNotification ........... 56.17ms DONE
The only thing I noticed is the emails that are sent tend to take 500ms or more. The ones that don't send tend to be 100ms or less.
Please or to participate in this conversation.