Skip to content

Commit b363fd8

Browse files
authored
Merge pull request #4 from i7an/batch-sending-api
Add batch sending to the main readme
2 parents 12b27e9 + 129955f commit b363fd8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,38 @@ client.send(
7373

7474
```
7575

76+
### Batch Sending
77+
78+
Send up to 500 emails in one API call:
79+
80+
```ruby
81+
require 'mailtrap'
82+
83+
client = Mailtrap::Client.new(api_key: 'your-api-key')
84+
85+
batch_base = Mailtrap::Mail.batch_base_from_content(
86+
from: { email: '[email protected]', name: 'Mailtrap Test' },
87+
subject: 'You are awesome!',
88+
text: 'Congrats for sending test email with Mailtrap!',
89+
html: '<p>Congrats for sending test email with Mailtrap!</p>'
90+
)
91+
92+
client.send_batch(
93+
batch_base, [
94+
Mailtrap::Mail.from_content(
95+
to: [
96+
{ email: '[email protected]', name: 'John Doe' }
97+
]
98+
),
99+
Mailtrap::Mail.from_content(
100+
to: [
101+
{ email: '[email protected]', name: 'Jane Doe' }
102+
]
103+
)
104+
]
105+
)
106+
```
107+
76108
### Email Templates API
77109

78110
```ruby
@@ -94,6 +126,7 @@ Refer to the [`examples`](examples) folder for more examples:
94126

95127
- [Full](examples/full.rb)
96128
- [Email template](examples/email_template.rb)
129+
- [Batch Sending](examples/batch.rb)
97130
- [ActionMailer](examples/action_mailer.rb)
98131
- [Email Templates API](examples/email_templates_api.rb)
99132

0 commit comments

Comments
 (0)