JeanValjean
JeanValjean

Reputation: 17713

Symfony2.1: email sent in HTML format seems to be escaped

In my Symfony2.1 application I'm using the SwiftMailer to send emails. Since I'm in dev mode, I'm not sending emails for reals. I control the output in the toolbar provided by the Profiler.

The email I'm sending is in HTML. So, to ensure HTML output I did the following settings:

$message = \Swift_Message::newInstance()
        ->setContentType("text/html")
        ->setSubject('Conferma registrazione nuovo utente')
        ->setFrom('[email protected]')
        ->setTo($email)
        ->setBody($this->renderView('AcmeMessageBundle:Contact:contact_request_email.html.twig', 'text/html');

$this->get('mailer')->send($message);

I suppose all the setting for HTML emails are ok. Notwithstanding that, I see that the emails sent are not shown as HTML in the Profiler dedicated area. In particular, all the HTML tags are escaped! Why? What am I missing in the settings?

Upvotes: 0

Views: 1377

Answers (1)

ChocoDeveloper
ChocoDeveloper

Reputation: 14588

For dev it is recommended to set up something like Gmail to deal with emails

# app/config/config_dev.yml
swiftmailer:
    transport: gmail
    username:  your_gmail_username
    password:  your_gmail_password

As for HTML emails, I can't tell exactly what's your problem, it could be anything. HTML emails are not easy (it's like developing for IE6), that's why a lot of devs just choose to send text emails.

Upvotes: 1

Related Questions