Skip to content

Commit 4b2a11b

Browse files
committed
Update README
1 parent d15737b commit 4b2a11b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ class User::WelcomeEmail < ApplicationEmail
106106
end
107107
```
108108

109+
### Send emails from the server
110+
109111
Then, to send the email.
110112

111113
```ruby
@@ -120,6 +122,41 @@ User::Welcome.new(user: User.first).message.tap do
120122
end.deliver_now
121123
```
122124

125+
### Launch the user's email client
126+
127+
Supermail clases can be used to generate `mailto:` links.
128+
129+
```erb
130+
<%= link_to Support::OrderEmail.new(
131+
user: current_user,
132+
order: @order
133+
).mail_to s%>
134+
```
135+
136+
This opens your users email client with prefilled information. A support email about an order might look like this:
137+
138+
```ruby
139+
class Support::OrderEmail < ApplicationEmail
140+
def initialize(user:, order:)
141+
@user = user
142+
@order = order
143+
end
144+
145+
def to = "[email protected]"
146+
def from = @user.email
147+
def subject = "Question about order #{@order.id}"
148+
def body = <<~BODY
149+
Hi Support,
150+
151+
I need help with my order #{@order.id}.
152+
153+
Thanks,
154+
155+
#{@user.name}
156+
BODY
157+
end
158+
```
159+
123160
## Development
124161

125162
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

0 commit comments

Comments
 (0)