Symfony Mailer: How to Create Emails | Templated Email | Mail Catcher - [Symfony Workshop 2021]

  Рет қаралды 13,013

Gary Clarke

Gary Clarke

Күн бұрын

Пікірлер
@HerNameEscapesMe
@HerNameEscapesMe 4 жыл бұрын
You've got a good knack for delving deep enough into periphery topics that crop up to explain them, without either glossing over them or getting completely sidetracked. Love your work so far mate, has helped give me the nudge I needed to try and learn docker. Easy to follow, and you don't skip over things. Keep it up mate, will likely tune in for everything you release.
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
Cheers Emlyn, I appreciate your support and good luck with Docker...it's a pretty big subject but just learn as much as you're likely to use because you just end up forgetting the rest anyway...like I have!
@vhur8836
@vhur8836 2 жыл бұрын
Gary To many known a random guy found on yt but to me he taught me how to use smfony i love Gary Thankl u Gary
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Welcome!
@ramo012032
@ramo012032 4 жыл бұрын
Very nice tuto, great content, keep up the great work 💪💪💪
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
Thank you ramo..I appreciate it. Plenty more to come!
@Trixxro
@Trixxro 3 жыл бұрын
Awesome tutorial! What editor are you using?
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Thanks..I appreciate it! Using PHPStorm with the Symfony Support plugin enabled.
@Trixxro
@Trixxro 3 жыл бұрын
Ty 👏
@thijsdew1988
@thijsdew1988 2 жыл бұрын
Hi Gary, thank you for the content. Would these settings work on a production env as well? Or do i have to change some settings if i'm going on a live server?
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Yes..you'd need to set it up for whichever 3rd party transport you use... symfony.com/doc/current/mailer.html#using-a-3rd-party-transport
@cprn.
@cprn. 3 жыл бұрын
Do you happen to know how to make `Email` properly build the message with some attachments inlined via `cid` in HTML content (in `related` part of the body) and some as actual attachments (in `mixed` part)? I can't seem to find an example other than working with raw `Message` object and everything I tried so far builds a message with either attached files or inline images but not both.
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Hmm..good question. I'll investigate.
@cprn.
@cprn. 3 жыл бұрын
@@GaryClarkeTech I kind of figured it out. Kind of. Don't know if KZbin comment will show code correctly but here it goes, typed on a phone: $email->html(""); # lands in `related` $email->embed($file['content'], $file['name'], $file['mimeType']); # lands in `related` $email->attach($file2['content'], $file2['name'], $file2['mimeType']); # lands in `mixed` File names have to be unique. It doesn't work in CSS, e.g. `background-image: url(cid:{$file['name']})`, and even if it would, Thunderbird doesn't render it - there's a 15 years old bug still active. It still doesn't work in Thunderbird sometimes. Don't know why yet. The reason I even asked is because I had attachment as `DataPart` like so: $embedded = new DataPart($file['content'], $file['name'], $file['mimeType']); $embedded->setInline(); $email->attachPart($embedded, $embedded->getContentId()); In this case `$file` Lands in `mixed` with disposition `inline` - it works in e.g. Gmail but Thunderbird requires it to be in `related` alongside `$html` to render properly as embedded image.
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
@@cprn. Impressive that you did that on a phone! 🙌
@anas1634
@anas1634 3 жыл бұрын
what about .env file? what is the value of MAILER_DSN?
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
That comes from docker-compose in this scenario, not the .env file Here's an explanation: symfony.com/doc/current/setup/symfony_server.html#docker-integration
@ApoRekt
@ApoRekt 2 жыл бұрын
does this work for symfony 6?
@ApoRekt
@ApoRekt 2 жыл бұрын
nope
@garetts8156
@garetts8156 2 жыл бұрын
@@ApoRekt just finished, everything works on Symfony 6 and PHP 8.1
@parijke
@parijke 3 жыл бұрын
Gary, if I want something to be templated in the database to assist for multiple languages, how would you approach that? i.e. I want to have this in a text field in my MailTemplate enity, something like: Dear {{user.Fullname }} Here's your invoice number {{invoice.number}} and render it using the TemplatedEmail() function...
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Hey Paul...it's not something I've tried but I'd probably avoid putting it in the DB, keep everything in email template files and use the Symfony translation service. I'll have a look at the translator in a future recording cos I'd like to get more familiar with it...I can try to recreate what you describe.
@parijke
@parijke 3 жыл бұрын
@@GaryClarkeTech thanks Gary. But in this case, the users can create email templates themselves. I.e. this is a boking system, so the owner of a property can create an email template as a welcome message. I don't see how to do that without creating the templates in the database?
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
@@parijke Ah right...I get you now. If they are all gonna be allowed to create something completely custom, then you can store the body as text in the DB and have placeholders which can be parsed and replaced with values such as names etc using string replace functions. Maybe do the find and replace first before passing it into a template as a $body variable. In fact, if you're using entities, you could build it into the email body getter function. Show me what you come up with and we can figure something out.
@parijke
@parijke 3 жыл бұрын
@@GaryClarkeTech ❤
@parijke
@parijke 3 жыл бұрын
Got it working it was even easier that I thought. I share a raw version, maybe you've got some ideas to improve if you have the time and are in to it
@sergemaminiaina252
@sergemaminiaina252 4 жыл бұрын
Thank you bro ^-^
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
You're welcome Serge
How to Create a Symfony Console Command
20:50
Gary Clarke
Рет қаралды 12 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
Symfony Webpack Encore Tutorial: Compiling JavaScript + CSS
17:05
Symfony 5 Avec Mailer
14:47
Symfony-friendly
Рет қаралды 14 М.
Symfony Forms Tutorial
16:57
Gary Clarke
Рет қаралды 26 М.
👨‍💻 Apprendre #Symfony 6 - Envoyer des emails #21
11:25
Développeur Musclé
Рет қаралды 15 М.
Symfony 5 Test Driven Development (TDD) Tutorial
1:25:00
Gary Clarke
Рет қаралды 46 М.
How to set up Docker, Celery, and Redis in a Django project
27:15
Nehemiah Kamolu
Рет қаралды 273
Symfony Messenger plus RabbitMQ
11:32
Gary Clarke
Рет қаралды 17 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН