Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails mailer styling

Why i recieve default style mail's on my mail? In code i style it a little bit, but why on gmail i see default layout? My code is such:

!!!
%html
  %head
    %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
      %title Покупка автозапчастей
      :css
        body, td { background-color:#cecece; color:#000000; font-size:14px; font-family:Verdana,Helvetica,Arial; }
        .blue { background-color: blue; height:2px; color: white; }
        .notice {margin: 10px auto;  background-color: #fbb752;  border: 1px solid #cecece; }
  %body
    .blue
      %h3
        Новый заказ
      %b
        Внимание, недавно на сайте сформирован новый заказ!
        = @order.id
    .notice
      %table
        %tr
          %th
            id клиента
          %th
            Улица
          %th
            Здание
          %th
            Общая сумма
          %th
            Статус
          %th
            Открыт
        %tr
          %td
            = @order.user.id
            = @order.user.email
          %td
            %b
              = @order.street
          %td
            = @order.building
          %td
            %b
              = @order.totalcost
          %td
            %b
              = @order.orderstatus.name
          %td
            = @order.created_at
      %br/
      %table
        %tr
          %th
            Артикул
          %th
            Цена
          %th
            Количество      
        - @order.line_items.each do |l|
          %tr{ :class => cycle("zebra-stripe zebra-grey zebra1", "zebra-stripe zebra-grey zebra2")}      
            %td
              = l.description
            %td
              = l.price
            %td
              = l.quantity

So how to do, that my mailer send on my e-mail service (gmail) good styled-letters as in my code?

like image 493
byCoder Avatar asked Apr 12 '26 10:04

byCoder


1 Answers

Gmail drops all <style> tags from HTML emails.

If you want your styles to appear in Gmail, you need to use inline style attributes.

like image 134
SLaks Avatar answered Apr 15 '26 00:04

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!