Sharim's avatar

How can I design an email

I'm using guzzlehttp/guzzle for sending emails through my Laravel application. I want to design the email that user will receive after placing an order. I have the blade file in my views folder but the styles and markup tags are not working. That's how I'm sending email

Mail::to($request->email)->send(new OrderPlaced($order));

Email Blade


@component('mail::table')
<table cellpadding="0" cellspacing="0">
 <tr class="information">
    <td colspan="4">
      <table>
         <tr>
            <td>
              {{$order->billing_name}}<br />
              {{$order->billing_phone}}<br />
              {{$order->billing_email}} <br />
              {{$order->billing_address}}<br />
              {{$order->area}},
              {{$order->state}}
            </td>
            <td>
               Order Tracking #: {{$order->tracking_id}}<br />
               Status: {{$order->status}} <br />
               Created: {{date('d-m-Y', strtotime($order->created_at))}}<br />
              </td>
         </tr>
      </table>
    </td>
  </tr>
  <tr class="heading">
    <td>Billing Details</td>
  </tr>
  <tr class="details">
    <td>Name on Card</td>
     <td class="text-right">{{$order->billing_name_on_card}}</td>
   </tr>
  <tr class="details">
     <td>Payment Method</td>
     <td class="text-right">{{$order->payment_gateway}}</td>
  </tr>
  <tr class="heading">
     <td>Products</td>
      <td>Quantity</td>
     <td class="text-right">Price</td>
     <td class="text-right">Total</td>
  </tr>
     @foreach($order->products as $product)
       <tr class="item">
         <td>{{$product->code}}</td>
          <td> {{ $product->pivot->quantity }} </td>
          <td class="text-right">AED.{{format($product->price)}}</td>
          <td class="text-right"> AED.{{ format($product->pivot->quantity * $product->price) }} </td>
       </tr>
     @endforeach
 </tr>
</table>
@endcomponent
0 likes
3 replies
Agbaje's avatar

If you are using Laravel email template, your table should be

@component('mail::table') | heading1 | heading2| heading3| | -------- |:--------:|---------:| | lorem Ip | lorem ip | lorem ip | @endcomponent

Sharim's avatar

@Agbaje How can I design it if I want to add some colors and size of the table?

Agbaje's avatar

@Sharim You need to run this command php artisan vendor:publish --tag=laravel-mail or better still, this might help h ttps://laracasts.com/discuss/channels/laravel/using-variables-in-markdown-email-theme-css

1 like

Please or to participate in this conversation.