Muhammad Usman
Muhammad Usman

Reputation: 215

"Postmark::InvalidMessageError: Provide either email TextBody or HtmlBody or both." for a rails 3.2 app

I was reading through the Postmark documentation, saw the rails gem there (github link).

I set it up according to the instructions and I ran into this message when I tried sending an email:

Provide either email TextBody or HtmlBody or both.

I have my email settings in my mailer as such:

mail(
  :to       => user.email,
  :subject  => "Thanks for signing up",
  :from     => "[email protected]",
  "HtmlBody" => "<b>Hello</b>",
  "TextBody" => "Hello"
)

Please let me know if you need more information. I'm not sure if this is detailed enough for someone who has seen this error before.

Upvotes: 3

Views: 2273

Answers (1)

Joshua Pinter
Joshua Pinter

Reputation: 47481

Misnaming Email Views

I ran into this same thing and it was due to a misnaming on my part of the views associated with the email.

Example

_user_first_logs_in.html.erb  # Was incorrectly using this.

user_first_logs_in.html.erb   # Should be using this.

A good way to test for this locally is by using the mail_view gem by our trusted 37signals boys that allows you to preview email in development. Check it out.

That should expose a lot of basic issues.

JP

Upvotes: 1

Related Questions