Search code examples
htmlcssemailgmailswiftmailer

Sending html and css mails to gmail with Swift Mailer


I have some basic html and some css but for some reason gmail puts 3D infornt the 'text/css'

Code sample

$message = "
            <style type='text/css'>
              #main {border:1px solid red;}
            </style>

              <div id='main'>some text</div>
";

But when I view the original send to the gmail

<style type=3D'text/css'>

and maybe thats why the mail is not styled. I am using the swift mailer

// also in html

<div id=3D'main'>

// swift mailer

    $type = $message->getHeaders()->get('Content-Type');
    $type->setValue('text/html');
    $type->setParameter('charset', 'utf-8');

Solution

  • From what I know gmail doesnt support style tag in head or in body. I use style attributes for elements when sending email.