Symfony

Mailer Component

Email service, transports, Twig email templates, attachments, inline images, Mailer events

16 pertanyaan wawancaraยท
Mid-Level
1

Which interface should be used to inject the email sending service in Symfony?

Jawaban

MailerInterface is the main interface for sending emails in Symfony. It exposes a send() method that accepts a RawMessage or Email object. Injecting this interface enables autowiring and facilitates mocking in unit tests.

2

How to configure the mailer DSN in Symfony?

Jawaban

The mailer DSN is configured via the MAILER_DSN environment variable. This approach follows Symfony best practices by separating sensitive configuration from code. The DSN format varies depending on the transport used (smtp, sendmail, or third-party services like mailgun, postmark, sendgrid).

3

Which class should be used to create an email with a Twig template?

Jawaban

TemplatedEmail is the dedicated class for creating emails using Twig templates. It extends the Email class and adds the htmlTemplate() and textTemplate() methods to specify templates. The context() method allows passing variables to the Twig template.

4

How to add an attachment to a Symfony email?

5

Which method allows embedding an image directly in the HTML body of an email?

+13 pertanyaan wawancara

Kuasai Symfony untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis