Skip to content

Commit 28a4071

Browse files
committed
Update code highlighting
1 parent d5b5448 commit 28a4071

File tree

1 file changed

+53
-41
lines changed

1 file changed

+53
-41
lines changed

README.md

+53-41
Original file line numberDiff line numberDiff line change
@@ -24,64 +24,76 @@ end
2424

2525
For direct usage of API
2626

27-
config :mailtrap,
28-
api_token: "PASTE TOKEN HERE"
27+
```elixir
28+
config :mailtrap,
29+
api_token: "PASTE TOKEN HERE"
30+
```
2931

3032
For Mailtrap Sandbox Bamboo adapter
3133

32-
config :test_mailtrap, TestMailtrap.Mailer,
33-
adapter: Bamboo.MailtrapSandboxAdapter,
34-
api_token: "PASTE TOKEN HERE",
35-
inbox_id: 111 # replace with your inbox id
34+
```elixir
35+
config :test_mailtrap, TestMailtrap.Mailer,
36+
adapter: Bamboo.MailtrapSandboxAdapter,
37+
api_token: "PASTE TOKEN HERE",
38+
inbox_id: 111 # replace with your inbox id
39+
```
3640

3741
For Mailtrap Sending Bamboo adapter
3842

39-
config :test_mailtrap, TestMailtrap.Mailer,
40-
adapter: Bamboo.MailtrapSendingAdapter,
41-
api_token: "PASTE TOKEN HERE"
43+
```elixir
44+
config :test_mailtrap, TestMailtrap.Mailer,
45+
adapter: Bamboo.MailtrapSendingAdapter,
46+
api_token: "PASTE TOKEN HERE"
47+
```
4248

4349
## Usage
4450

4551
Sending to Mailtrap Sandbox API
4652

47-
client = Mailtrap.Sandbox.client("PASTE TOKEN HERE")
48-
email = (%Mailtrap.Email{}
49-
|> Mailtrap.Email.put_from({"From name", "[email protected]"})
50-
|> Mailtrap.Email.put_to({"Recepient", "[email protected]"})
51-
|> Mailtrap.Email.put_subject("Hi there")
52-
|> Mailtrap.Email.put_text("General Kenobi"))
53-
Mailtrap.Sandbox.send(client, email, 111) # replace 111 with your inbox id
53+
```elixir
54+
client = Mailtrap.Sandbox.client("PASTE TOKEN HERE")
55+
email = (%Mailtrap.Email{}
56+
|> Mailtrap.Email.put_from({"From name", "[email protected]"})
57+
|> Mailtrap.Email.put_to({"Recepient", "[email protected]"})
58+
|> Mailtrap.Email.put_subject("Hi there")
59+
|> Mailtrap.Email.put_text("General Kenobi"))
60+
Mailtrap.Sandbox.send(client, email, 111) # replace 111 with your inbox id
61+
```
5462

5563
Sending via Mailtrap Sending API
5664

57-
client = Mailtrap.Sending.client("PASTE TOKEN HERE")
58-
email = (%Mailtrap.Email{}
59-
|> Mailtrap.Email.put_from({"From name", "[email protected]"})
60-
|> Mailtrap.Email.put_to({"Recepient", "[email protected]"})
61-
|> Mailtrap.Email.put_subject("Hi there")
62-
|> Mailtrap.Email.put_text("General Kenobi"))
63-
Mailtrap.Sending.send(client, email)
65+
```elixir
66+
client = Mailtrap.Sending.client("PASTE TOKEN HERE")
67+
email = (%Mailtrap.Email{}
68+
|> Mailtrap.Email.put_from({"From name", "[email protected]"})
69+
|> Mailtrap.Email.put_to({"Recepient", "[email protected]"})
70+
|> Mailtrap.Email.put_subject("Hi there")
71+
|> Mailtrap.Email.put_text("General Kenobi"))
72+
Mailtrap.Sending.send(client, email)
73+
```
6474

6575
### Bamboo adapter
6676

67-
# mailer module
68-
defmodule TestMailtrap.Mailer do
69-
use Bamboo.Mailer, otp_app: :test_mailtrap
70-
end
71-
72-
# generate email
73-
def welcome_email(subject \\ "Hi there", friendly_name \\ "Recepient", to \\ "[email protected]") do
74-
new_email(
75-
to: {friendly_name, to},
76-
from: {"From", "[email protected]"},
77-
subject: subject,
78-
html_body: "<strong>Thanks for joining!</strong>",
79-
text_body: "Thanks for joining!"
80-
)
81-
end
82-
83-
# send
84-
welcome_email() |> TestMailtrap.Mailer.deliver_now()
77+
```elixir
78+
# mailer module
79+
defmodule TestMailtrap.Mailer do
80+
use Bamboo.Mailer, otp_app: :test_mailtrap
81+
end
82+
83+
# generate email
84+
def welcome_email(subject \\ "Hi there", friendly_name \\ "Recepient", to \\ "[email protected]") do
85+
new_email(
86+
to: {friendly_name, to},
87+
from: {"From", "[email protected]"},
88+
subject: subject,
89+
html_body: "<strong>Thanks for joining!</strong>",
90+
text_body: "Thanks for joining!"
91+
)
92+
end
93+
94+
# send
95+
welcome_email() |> TestMailtrap.Mailer.deliver_now()
96+
```
8597

8698
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
8799
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can

0 commit comments

Comments
 (0)