Using Trix as an editor for email content
I was wondering if anyone had any experience with using data produced from a Trix field to be uses as the content of an HTML email.
Since, styling and dom element support is pretty rough in emails, I was wondering if its just a lost cause to try to use trix for this use case. I dont need complex layout capabilities, but giving users a section to customize, include images, et al would be really awesome.
http://hey.com uses Trix and is an email provider. I use Hey, so I have daily experience with data produced from a Trix field to be used as content in an HTML email.
Trix, afaik, doesn't do anything special with your HTML, underneath the hood is plain 'ol HTML. Any email provider will take your HTML and parse it to their needs.
I've used Trix and Rails to create an email solution for one of my apps. Sending is easy, it's the receiving that's problematic if you care about format.
The problem is that the content received by ActionMailbox is obviously not compatible with Trix, so you need parsers for each major provider, Outlook, Gmail, and Apple's Mail. Or, if you know regex, you can create one parser to rule them all.
@maxwell I use it in my app. Users create emails using trix and if they have images I replace the attachment for an image. Like this
def body
doc = Nokogiri::HTML(params[:email].content.body.to_html)
doc.css('action-text-attachment').each do |attachment|
img = doc.create_element 'img'
img['src'] = attachment['url']
img['style'] = 'max-width: 100%;'
attachment.replace img
end
doc.to_s
end
Hi @pacMakaveli, our team is having a hard time figuring out how to parse incoming HTML emails on the backend to be compatible with Trix. I work on the front end and inserting them after serialization produces an absolute mess. Please can you share a bit on how these parsers would work?