'How can I translate the markdown email template ?
I tried to use __() inside the template but it doesnt work.
My template :
<x-mail::message>
# Password
__{{'Your password is'}} : {{ $password }} // it is displaying without being translated
</x-mail::message>
Try using the #lang directive and publish your language files using php artisan lang:publish.
#lang('Your password is') : {{ $password }}
Related
I am trying to use localization in the Laravel markdown mail template, followed the manual but emails are not being translated when I receive it.
Calling the mail method:
Mail::to($email)->locale('no')->queue(new UserRegistered($data));
and my markup email template is:
#component('mail::message')
{{ __('A new user registration request has been received.') }} // it is displaying without being translated
{{ __('Test String') }} // it is displaying without being translated
{{ trans('Test String') }} // it is displaying without being translated
#lang('Test String') // it is displaying without being translated
#endcomponent
I have my en.json and no.json files in lang directory
{
"Test String": "Teststreng"
}
I'm trying to embed an image into my markdown email but it's not loading correctly.
https://i.imgur.com/lNCwhod.png
This is my mail template:
#component('mail::message')
# {{ $mailData['title'] }}
![{{ $mailData['appName'] }}]({{ asset($mailData['image'])}})
{!! $mailData['body'] !!}
Saludos,
{{ $mailData['appName'] }}
#endcomponent
This is the value of $mailData['image']:
'/img/misc/default.jpg'
Any idea how I can do this?
You can use html to add an image to your markdown:
#component('mail::message')
# {{ $mailData['title'] }}
<img src="{{asset('img/logo.png')}}" style="width:30%" alt="App Logo">
...
#endcomponent
Also you can use the style tag to customize the image.
Be aware if you are in localhost, you aren't going to see the image in the email (unless you are using mailhogh to test your emails).
As far as I know, the image has to be in your server hosted, so the image will not attached on the email.
Your server need an IP public or a domain to be able to see the images within the email.
You can try this markdown:
![Image_Alter_Text](PAHT_OF_IMAGE)
You have to pass complete path of image, and you get complete path by using Storage::url($file_name). Store image path in variable and pass in markdown.
For example :
![DemoImage](https://i.stack.imgur.com/bENi3.jpg)
Note: The image (logo of stackoverflow) is used in this comments is only for demo purpose.
Hi I am trying to use MailMessage function in my Laravel App. My question is very simple. How to edit the Header and the Footer when receiving email from the app? Here is the picture below.
I want to change the header Laravel from my App name and the Hello with a Hello $user->name and the Regards, with my App name also and the footer below to the App name also.
I tried to change the `
resources/views/vendor/mail/markdown/message.blade.php
To:
#component('mail::layout')
{{-- Header --}}
#slot('header')
#component('mail::header', ['url' => config('app.url')])
CCTV App
#endcomponent
#endslot
{{-- Body --}}
{{ $slot }}
{{-- Subcopy --}}
#isset($subcopy)
#slot('subcopy')
#component('mail::subcopy')
CCTV Team
#endcomponent
#endslot
#endisset
{{-- Footer --}}
#slot('footer')
#component('mail::footer')
© {{ date('Y') }} CCV3. All rights reserved.
#endcomponent
#endslot
#endcomponent
But not working when I send a reset password request
Would really appreciate if someone can help me.
Thanks in advance.
`
I want to change the header Laravel from my App name and the Hello with a Hello $user->name and the Regards, with my App name also and the footer below to the App name also
Mailable Markdown by default has the config('app.name') that picks the APP_NAME from your .env file. So by modifying the APP_NAME will effect on your markdown template.
OR if you modifying it manually, run the following command on your terminal
php artisan vendor:publish --tag=laravel-mail and go to the resources/views/vendor/mail/html/message.blade.php and modify the header and footer slot.
For changing Hello to Hello {user_name}, there is markdown called greeting() method that holds Hello!, you can change it whatever you want.
For Regards run this command on your terminal
php artisan vendor:publish --tag=laravel-notifications and go to the resources/views/vendor/notifications/email.blade.php and modify the Regards whatever you want.
To know more in details take a look on customizing markdown email.
I already figure it out just change the name of the env file to your App name instead of laravel. This is the sample below.
APP_NAME=Laravel
Change it to
APP_NAME=YOUR_APP_NAME
there is also one way to edit your mail template.
Just go to resources/views/vendor/notifications/email.blade.php
and you can also edit the message to your mail just go to resources/views/vendor/markdown/message.blade.php
You are using default component for your email template named #component('mail::message'), It does not allow you to modify header. But if you go to the file of this component,
\vendor\laravel\framework\src\Illuminate\Mail\resources\views\markdown\message.blade.php
you will notice that it uses another component #component('mail::layout'),
Just copy content of message.blade.php file into your .blade.php and replace {{ $slot }} with what you had in your file before.
And you are done.
I have an given template file with following content:
Welcome, {{ user }}
In my PHP File I load this content by:
$welcome = file_get_contents(APPPATH . 'classes/Plugins/Core/testplugin/view/frontend/index.html');
So that's in template:
"Welcome, {{ user }}"
Now, if I give this content into my template:
$twig->welcome = $welcome;
$twig->user = "Tom";
Template output (html):
{{ welcome }}
Template output (browser):
Welcome, {{ user }}
My problem: Template engine won't replace my user given in twig string!
Any ideas? I tried using following filters:
{{ welcome|nl2br|raw }}
So you have a string in your template which in itself is a template. Then you need to tell Twig to treat your template variable as a template, otherwise it'll just treat it as string. For this there's the template_from_string function.
I used a very simple template (.tpl) for receive emails in my php application. Some similar this:
Date : {date}
Name : {name}
Mail : {email}
Subject : {subject}
{message}
Now, I have migrated this app to Symfony, ¿how can I used this template?
If I do:
$this->renderView('MyBundle:Template:support.tpl', $params), 'text/html');
This not work in Symfony2.
Any Idea??
Thanks!
Symfony doesn't know .tpl files and your syntax. Simply use twig!
Date : {{ date }}
Name : {{ name }}
Mail : {{ email }}
Subject : {{ subject }}
{{ message }}
Of course your file have to end to .twig
$this->renderView('MyBundle:Template:support.txt.twig', $params);