ruby on rails - SendGrid not Preserving ActionMailer Template -
i have rails 4 app on heroku uses sendgrid. created mailer shows digest of user's recent social media posts using twitter's oembed api. problem is, when send message , view in inbox, it's plain text , social media posts missing. not that, none of styling persisted.
what know how preserve template generated mailer user gets nicely formatted html email.
here current sendgrid seetings:
actionmailer::base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => env['sendgrid_username'], :password => env['sendgrid_password'], :domain => 'heroku.com', :enable_starttls_auto => true }
i'll post mailer code well, don't know if it's relevant issue. other mailers plain text messages.
<!doctype html> <html> <head> <meta content='text/html; charset=utf-8' http-equiv='content-type' /> <%= stylesheet_link_tag "employers", media: "all" %> </head> <body> <div class="panel panel-default"> <div class="panel-body"> <div class="email"> hi <%= "#{@contact.first_name}" %>, <br /><br /> we’re working hard let know it’s work here @ <%= @company.name %> – it’ll recruit smarter , faster. <br /><br /> amazing if share following on social media – click on social media buttons! <br /> <br style="clear:both" /> <div class="results-label"><b>recent tweets</b></div> <% @tweets.each |tweet| %> <%= @company.twitter_client.oembed(tweet, width: 550).html.html_safe %> <% end %> <div class="results-label"><b>recent linkedin posts</b></div> <div class="column-layout cols-1 search-results"> <div style="max-width: 640px;"> <% @linkedin_posts.each |post| %> <div class="card result-link"> <div class="content result result-post"> <div class="post-textarea"> <div class="social"> <div class="buttons"> <a class="square-btn-med li" href="https://www.linkedin.com/nhome/updates?topic=<%= post.linkedin_id %>"><%= image_tag "icons-ebt.png" %></a> </div> </div> <div class="date-info"> <%= "#{post.created_at.in_time_zone("eastern time (us & canada)").strftime("%a, %b %d, %y")} | #{post.created_at.in_time_zone("eastern time (us & canada)").strftime("%l:%m %p %z")}" %> </div> <br style="clear:both" /> <div class="post"><%= "#{post.post}" %></div> </div> <% if post.attachment_url && post.media_url %> <a class="square-btn-med li" href="https://www.linkedin.com/nhome/updates?topic=<%= post.linkedin_id %>"> <div class="image-container social-media-post" style="background-image: url(<%= post.attachment_url %>)"></div> </a> <% elsif post.attachment_url && !post.media_url %> <div class="image-container social-media-post" style="background-image: url(<%= post.attachment_url %>)"></div> <% end %> </div> </div> <% end %> </div> </div> </div> <br style="clear:both" /> <br /> thanks, <br /> <%= @employer_name %> </div> </div> </body> </html>
here mailer code:
class promotionmailer < actionmailer::base default from: 'myapp <info@myapp.com>' def new_promotion(contact, company, link, employer_name, employer_email) @contact = contact @company = company @link = link @subject = "help showcase #{@company.name}’s company culture!" @employer_name = employer_name mail(to: @contact.email, from: employer_email, subject: @subject) end end
Comments
Post a Comment