mailslurp_client 15.18.3 → 15.18.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +66 -9
- data/lib/mailslurp_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9850049a30de9796cb1b3c6b0a679e85157c74c8dc590e4bc0f5435208ad30b5
|
4
|
+
data.tar.gz: 3af4a3d03795e2d91bb4ff2fed4408812fe2a9c9c4fc61e1d5386c4bee207228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2e88f73b596989c7812d50493b71f198c7c867231b78266c15e8579772147f35b081c25be2f5c6d5bee9874e1981127839b94cedf74ee5e4f108b94455d587b
|
7
|
+
data.tar.gz: d8fec58d243f4e8e0f4dbb7ba469c4dc56d15f81c434bf017418190154bd61d28ced0eaa83ff2321f66128a1ba11eaacba31ebf30e95426922595eb3731b122b
|
data/README.md
CHANGED
@@ -50,7 +50,12 @@ gem install mailslurp_client
|
|
50
50
|
|
51
51
|
Or in your `Gemfile`:
|
52
52
|
|
53
|
-
|
53
|
+
```ruby
|
54
|
+
source "https://rubygems.org"
|
55
|
+
|
56
|
+
gem 'mailslurp_client'
|
57
|
+
gem 'typhoeus'
|
58
|
+
```
|
54
59
|
|
55
60
|
And then run bundler install:
|
56
61
|
|
@@ -67,15 +72,22 @@ You may need to install `typhoeus` if you encounter libcurl errors.
|
|
67
72
|
gem 'typhoeus'
|
68
73
|
```
|
69
74
|
|
70
|
-
|
71
75
|
### Configure the client
|
72
76
|
|
73
|
-
|
77
|
+
```ruby
|
78
|
+
require 'mailslurp_client'
|
79
|
+
|
80
|
+
MailSlurpClient.configure do |config|
|
81
|
+
config.api_key['x-api-key'] = ENV['API_KEY']
|
82
|
+
end
|
83
|
+
```
|
74
84
|
|
75
85
|
### Create controllers
|
76
86
|
To call the API create a controller like this:
|
77
87
|
|
78
|
-
|
88
|
+
```ruby
|
89
|
+
inbox_controller = MailSlurpClient::InboxControllerApi.new
|
90
|
+
```
|
79
91
|
|
80
92
|
## Common uses
|
81
93
|
|
@@ -87,7 +99,14 @@ Here are some common uses:
|
|
87
99
|
|
88
100
|
To use MailSlurp you need to create inboxes. These are email accounts that have an ID and a real email address. See methods on the [inbox controller](https://ruby.mailslurp.com/MailSlurpClient/InboxControllerApi.html) for more information.
|
89
101
|
|
90
|
-
|
102
|
+
```ruby
|
103
|
+
options = {
|
104
|
+
name: "My test inbox",
|
105
|
+
inboxType: "SMTP_INBOX"
|
106
|
+
}
|
107
|
+
inbox = inbox_controller.create_inbox_with_options(options)
|
108
|
+
assert_match /@mailslurp/, inbox.email_address
|
109
|
+
```
|
91
110
|
|
92
111
|
In a test:
|
93
112
|
|
@@ -199,7 +218,13 @@ end
|
|
199
218
|
|
200
219
|
You can send HTML emails easily with the inbox controller. First create an inbox then use its ID with the `send_email` method.
|
201
220
|
|
202
|
-
|
221
|
+
```ruby
|
222
|
+
inbox_controller.send_email(inbox.id, {
|
223
|
+
to: [inbox.email_address],
|
224
|
+
subject: "Hello",
|
225
|
+
body: "Welcome. Your code is: 123456",
|
226
|
+
})
|
227
|
+
```
|
203
228
|
|
204
229
|
To send attachments see the [Method Documentation](https://ruby.mailslurp.com/).
|
205
230
|
|
@@ -242,7 +267,27 @@ inbox_controller.send_email(inbox_1.id, opts)
|
|
242
267
|
|
243
268
|
### Send with SMTP
|
244
269
|
|
245
|
-
|
270
|
+
```ruby
|
271
|
+
require 'net/smtp'
|
272
|
+
access_details = inbox_controller.get_imap_smtp_access(inbox_id: inbox.id)
|
273
|
+
Net::SMTP.start(
|
274
|
+
address= access_details.secure_smtp_server_host,
|
275
|
+
port= access_details.secure_smtp_server_port,
|
276
|
+
helo= inbox.email_address.match(/@(.+)/)[1],
|
277
|
+
user= access_details.secure_smtp_username,
|
278
|
+
secret= access_details.secure_smtp_password,
|
279
|
+
authtype= :plain
|
280
|
+
) do |smtp|
|
281
|
+
message = <<EOF
|
282
|
+
Subject: SMTP test
|
283
|
+
|
284
|
+
This is my body
|
285
|
+
EOF
|
286
|
+
smtp.send_message message, inbox.email_address, inbox.email_address
|
287
|
+
smtp.finish
|
288
|
+
end
|
289
|
+
|
290
|
+
```
|
246
291
|
|
247
292
|
### Receive emails
|
248
293
|
|
@@ -250,11 +295,23 @@ To read already existing emails use the [Email Controller](https://ruby.mailslur
|
|
250
295
|
You can use MailSlurp to wait for at least 1 unread email in an inbox and return it.
|
251
296
|
If a timeout is exceeded it will throw an error instead:
|
252
297
|
|
253
|
-
|
298
|
+
```ruby
|
299
|
+
wait_for_controller = MailSlurpClient::WaitForControllerApi.new
|
300
|
+
wait_options = {
|
301
|
+
inbox_id: inbox.id,
|
302
|
+
timeout: 120000,
|
303
|
+
unread_only: true
|
304
|
+
}
|
305
|
+
email = wait_for_controller.wait_for_latest_email(wait_options)
|
306
|
+
assert_match /Welcome/, email.body
|
307
|
+
```
|
254
308
|
|
255
309
|
### Extract email content
|
256
310
|
|
257
|
-
|
311
|
+
```ruby
|
312
|
+
code = email.body.match(/Your code is: ([0-9]{6})/)[1]
|
313
|
+
assert_equal code, '123456'
|
314
|
+
```
|
258
315
|
|
259
316
|
To parse an email and extract content use regex patterns like so:
|
260
317
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailslurp_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 15.18.
|
4
|
+
version: 15.18.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mailslurp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Create emails addresses in Ruby then send and receive real emails and
|
14
14
|
attachments. See https://www.mailslurp.com/ruby/ for full Ruby documentation. Get
|