<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Aboubakary833</title>
    <description>The latest articles on Forem by Aboubakary833 (@aboubakary833).</description>
    <link>https://forem.com/aboubakary833</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F574758%2F3d1602c2-9b5e-4144-a9d7-e9d80bf78315.png</url>
      <title>Forem: Aboubakary833</title>
      <link>https://forem.com/aboubakary833</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aboubakary833"/>
    <language>en</language>
    <item>
      <title>Queuing Laravel email verification</title>
      <dc:creator>Aboubakary833</dc:creator>
      <pubDate>Thu, 14 Sep 2023 15:43:38 +0000</pubDate>
      <link>https://forem.com/aboubakary833/queuing-laravel-email-verification-5033</link>
      <guid>https://forem.com/aboubakary833/queuing-laravel-email-verification-5033</guid>
      <description>&lt;p&gt;When building a Laravel application, one may want the user to verify their email address to avoid fake users. Generally, this email verification process is done behind the scenes just after the user has registered on your application. After we store the user information in the database, we dispatch an event that automatically sends the verification mail to that user. However, the registration and verification process can sometimes delay the following code execution. For example, we could want to respond quickly to the user to signify that his registration passed. What we could do to speed up our users' registration is to queue our email verification.&lt;br&gt;
To achieve that, we should:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I suggest referring to the &lt;a href="https://laravel.com/docs/10.x/queues" rel="noopener noreferrer"&gt;Laravel documentation&lt;/a&gt; if you're unfamiliar with queuing tasks.&lt;/p&gt;

&lt;p&gt;First, create a new notification that extends the Laravel &lt;strong&gt;Illuminate\Auth\Notifications\VerifyEmail&lt;/strong&gt; notification class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvr4kwdm6v8koepuj1emx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvr4kwdm6v8koepuj1emx.png" alt="Our SendVerificationEmail notification class"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ensure that your &lt;strong&gt;SendVerificationEmail&lt;/strong&gt; notification class implements the &lt;strong&gt;ShouldQueue&lt;/strong&gt; interface as shown in the figure.&lt;/p&gt;

&lt;p&gt;Then in your &lt;strong&gt;App\Models\User&lt;/strong&gt; class, override the &lt;strong&gt;sendEmailVerificationNotification&lt;/strong&gt; method to make it send &lt;strong&gt;SendVerificationEmail&lt;/strong&gt; notification instead of &lt;strong&gt;Illuminate\Auth\Notifications\VerifyEmail&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcpvmeymlhvk1vwlk3p9o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcpvmeymlhvk1vwlk3p9o.png" alt="Overriding the sendEmailVerificationNotification method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a user registers and the &lt;strong&gt;Illuminate\Auth\Events\Registered&lt;/strong&gt; event is dispatched, the verification email-sending process runs in the background and let the following code execute without being interrupted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This article is only about queuing email verification. We could not go deep because it is a tip that I quickly wanted to share with you. I hope you have found it helpful.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>verification</category>
      <category>queue</category>
    </item>
  </channel>
</rss>
