Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Paweł Świątkowski
@katafrakt@ruby.social  ·  activity timestamp last week

Earlier today @bradgessler published Supermail for ActionMailer and I started to think that I would like to have this API for emails in #Hanami too.

So now I kind of do, although there is probably a lot of edge cases to discover.

Sorry, no caption provided by author
Sorry, no caption provided by author
Sorry, no caption provided by author
  • Copy link
  • Flag this post
  • Block
Paweł Świątkowski
@katafrakt@ruby.social replied  ·  activity timestamp last week

The trade-off is that the API does not play well with Hanami Deps system. But I think this is what I'm willing to sacrifice.

Sorry, no caption provided by author
Sorry, no caption provided by author
Sorry, no caption provided by author
  • Copy link
  • Flag this comment
  • Block
Tim Riley
@timriley@ruby.social replied  ·  activity timestamp last week

@katafrakt we could also wrap it in a more Hanami-friendly adapter class in prolly less then a dozen lines of code :)

“Emails” are still on the do-do list for Hanami! How do you think we should do them? (If at all)

  • Copy link
  • Flag this comment
  • Block
Paweł Świątkowski
@katafrakt@ruby.social replied  ·  activity timestamp last week

@timriley I didn't have any crystallized thoughts about what email should look like. This is part of the reason I wanted to experiment with different approaches to see how they feel. This is the result I kind of liked.

1. I agree with Brad that methods (`def from = 'mail'`) feel better than DSL (`from 'mail'). This makes it crystal clear how inheritance works and how I can extract reusable parts as modules to include.

  • Copy link
  • Flag this comment
  • Block
Paweł Świątkowski
@katafrakt@ruby.social replied  ·  activity timestamp last week

@timriley
2. I guess making it Hanami-way would mean an API similar to the current mailer, i.e. `RegMail.new.deliver(user:)`. What I don't like about this is that if I have `RegMail.new.deliver_in(3600, user:)`, it mixes args for email building with args for delivery. So separate passing email building params to initializer makes more sense (`RegMail.new(user:).deliver_in(3600)`).

  • Copy link
  • Flag this comment
  • Block
Damian C. Rossney
@dcrossney@ruby.social replied  ·  activity timestamp last week

@timriley @katafrakt

Does Sebs' work using the Hanami 1.x mailer with Hanami 2 offer any help?

https://hanamimastery.com/episodes/47-send-emails-with-hanami-mailer

Hanami Mastery - a knowledge base to hanami framework

Send emails with hanami-mailer

Sending emails in web apps is a very common task. In this video, I'm going to send a contact email using hanami-mailer gem.
  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.1 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login