Render Text of Mandrill Template with API - mandrill

Is there a way to get the rendered Text and not just HTML from the Mandrill API? I would like to be able to test that merging produces the correct output in text version of emails. /templates/render.json doesn't look like it returns 'text'.

Related

Posting to a web form and catching results from JavaScript code

How would I go about achieving the following
I have some HTML data triggered from an Evernote new note action
I need to pass this HTML string to a website via an http post with form variables
I then need to catch the resulting web page text in a variable to use in my next action.
For clarity the website simply takes some HTML and converts it to markdown passing it back out as the body of the resulting page
Regards in advance
Dan
Sweet! So I've got this working. In my example, text is some html I pulled out of a dummy previous step:
The output is:
Which has the markdown as a key. If you want to tweak other data based on the api params, you can do that as GET params below html
​Let me know if you've got any other questions!

Mailboxer html formattting

How can I allow Mailboxer gem to send HTML formatted messages?
For example, I want the first message user A sends to user B to be pre-formatted with certain text and HTML tags. Currently any kind of markup is escaped..
EDIT: My question is basically how can I "patch" the send_message functionality? Or create a new send_message2 that behaves the way I want?

How to get the email message body with ActionMailer

I am sending an standard email with Rails like this
#mail = mail(to: registration.user.email, subject: "Registration Confirmation: #{#site.name}")
Now i need to get the message body (or html in this case) from the email. I tried the following but it does not work since it returns not the rendered email but rather the template (including ERB and Haml).
#mail.body
#mail.body.raw_source
#mail.body.encoded
It seems surprisingly difficult to do this. I need the result that a persons sees when receiving the email.
Update
The ERB and Haml i saw was an HTML comment, that's why in the logs it looked like it logged ERB instead of a rendered tempalte. So #mail.body.encoded works fine.
I tried the accepted answer but it is showing the HEADER along with HTML. To get the HTML tags only I've used below code:
#mail.html_part.body.decoded
How about #mail.body.encoded (which should give you the result for which you seek)?

Using Render in my .rb file

Hi I have some html in a file called (a partial):
_quotemail.html.erb
I Am sending an email to a user and I want to put this html in the email. I am using mailgun.
I can define my email body like so:
body = "text to go in email"
which works great but I want to instead include the HTML I have in my quotemail partial.
Whats the best way to do this?

How to write tests for email views in Rails?

In ActiveAdmin I have setup a small form for sending bulk emails to users. In the form I have the option to parse text using html or markdown. I have two different views and depending on the content type attribute of the email, one of the two is rendered. I pass the #content of the email to the views and in the one I call simple_format #content and in the other - a helper method markdown #content. So the question is - how do I test the email views. Everywhere I see ways to preview emails in the browser, but I want to have some written tests, which I can run along with my full test suit. So far, the only idea I have come up with is to use Capybara and something like:
visit '/mail_view'
expect(find 'a.reset_password').to contain reset_password_path(user)
Is this the way to go or is there another standard?

Resources