Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Emmanuel-Mtz-777/TechStore-Explorer/llms.txt

Use this file to discover all available pages before exploring further.

TechStore Explorer sends two transactional emails triggered by wishlist actions — both delivered asynchronously via Laravel’s queue system using Mailtrap Sandbox SMTP in development. Because both mail classes implement ShouldQueue, dispatch returns immediately and the HTTP response is never delayed by mail delivery; a separate queue worker picks up and processes each job in the background.

Email Events

Two Mailable classes handle wishlist notifications, each rendering its own Blade view:

WishlistAddedMail

Sent when a user adds a product to their wishlist. The mail receives the product as a constructor argument and passes it to its template, which displays the product price.
  • Subject: Producto añadido a favoritos
  • View: emails.wishlist-added
  • Template content: confirms the addition and displays the product price ($product['price'])

WishlistDeletedMail

Sent when a user removes a product from their wishlist.
  • Subject: Producto Eliminado de favoritos
  • View: emails.wishlist-deleted
  • Template content: confirms the removal and encourages the user to continue browsing

How Queuing Works

Emails are not sent inline — they are pushed onto the queue with Mail::to(...)->queue(...) inside the web WishlistController. The dispatched job is serialized and stored as a row in the jobs database table. The queue worker process (php artisan queue:work) polls that table continuously and sends each email when its turn arrives. This means two processes must be running simultaneously for email delivery to work:
  1. The Laravel web server — handles HTTP requests and enqueues mail jobs
  2. The queue worker — dequeues and dispatches the actual emails via SMTP

Setting Up Mailtrap

1

Create a free Mailtrap account

Go to mailtrap.io and sign up for a free account. No credit card is required for the Sandbox plan, which is sufficient for development and testing.
2

Open Email Testing → Inboxes

After logging in, navigate to Email TestingInboxes in the left sidebar. Select an existing sandbox inbox or create a new one specifically for TechStore Explorer.
3

Copy your SMTP credentials

Inside the inbox, click Show Credentials (or select the SMTP integration tab). Copy the Username and Password values — you will need these in the next step.
4

Update your .env file

Open your project’s .env file and replace the mail block with your Mailtrap credentials:
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=no-reply@example.com
MAIL_FROM_NAME="${APP_NAME}"
Replace your_username and your_password with the values copied from the Mailtrap dashboard.
5

Start the queue worker

In a separate terminal, start the queue worker so it can process email jobs as they arrive:
php artisan queue:work
Keep this terminal open for as long as you are testing email functionality. The worker will log each processed job to the console.
6

Trigger a wishlist action and verify delivery

With both the web server and the queue worker running, log in to TechStore Explorer and add or remove a product from your wishlist. Switch to the Mailtrap dashboard — the notification email will appear in your sandbox inbox within seconds.

Environment Variables Reference

The complete mail configuration block for your .env file:
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=no-reply@example.com
MAIL_FROM_NAME="${APP_NAME}"

Queue Driver Note

The default QUEUE_CONNECTION=database (set in .env.example) stores all pending jobs in the MySQL jobs table. This requires no additional infrastructure beyond the database already used by the application. During testing you can switch to the sync driver, which executes mail jobs inline and synchronously — no worker process is needed:
QUEUE_CONNECTION=sync
Be aware that sync blocks the HTTP response until the SMTP transaction completes. It is convenient for quick verification but should not be used in production or for any endpoint where response time matters.
If the queue worker is not running while QUEUE_CONNECTION=database is active, every wishlist email will be serialized and stored in the jobs table but will never be sent. Jobs accumulate silently — there is no error shown to the user. Always confirm the worker is active before testing email delivery.
Running composer run dev starts the queue worker automatically alongside the web server, Vite, and the Laravel log watcher — all in a single terminal session with colour-coded output. This is the recommended way to run the full development environment locally.

Build docs developers (and LLMs) love