I'm trying to send an email when user submits a form in laravel. So in my Controller I have :
Mail::to($request->to)->send(new \App\Mail\ShareEbol());
And in my ShareEBOL
class, in build method I have:
public function build()
{
return $this->markdown('panel.reports.ebol');
}
And in my ebol.blade.php
file I have:
@extends('layouts.app')
@section('content')
<h2 class="my-custom-header"> Hello World </h2>
<p class="my-custom-paragraph"> some text... </p>
@endsection
And in my layouts.app
blade file I have appended some stylesheets :
<link href="{{asset('assets/css/custom.css')}}" rel="stylesheet" type="text/css" />
Email is sent successfuly, but the problem is css styles that I have included in custom.css
are not applied in email. How can I fix this?
The template of Laravel mail can be configured as follows, To configure the routes, create the route by writing the code to the web.php file. The controller file is created with the standard user-preferred name and it should be scripted along with the home controller code.
Laravel allows you to send mailables in a locale other than the request's current locale, and will even remember this locale if the mail is queued. To accomplish this, the Mail facade offers a locale method to set the desired language.
SwiftMessage can be customized using withSwiftMessage method of Mailable base class: https://laravel.com/docs/8.x/mail#customizing-the-swiftmailer-message However you have to remember to do it every time you create a new “mailable” class. Some mail APIs require you to put a special header each time you send an email.
The process for using Tailwind CSS in Laravel e-mails is a simple four-step proces: Create an e-mail template and use Tailwind CSS in the template. Create a separate CSS-file ( mail.css) and run Tailwind CSS with a separate config.
It seems that you had created your custom ui. so I try to help based on your custom need.
Option 1:
Create path html/themes
. for example: resources/views/panel/reports/ebol/html/themes
copy your custom.css
to html/themes
edit config/mail.php
like below:
...
'markdown' => [
'theme' => 'custom', // custom.css
'paths' => [
resource_path('views/panel/reports/ebol'),
],
],
Now default theme for all markdowns will be custom.css
Option 2:
another option is to set the theme using $theme
property of mailable class instead of setting that in config/mail.php
for example:
class ShareEbol extends Mailable
{
use Queueable, SerializesModels;
public $theme = 'custom'; // custom.css
...
Option 3:
another option is to use Mail Notifications
that is well documented here : Laravel Mail Notifications
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With