MailSlurp has many methods for sending and receiving emails. Here are three main ways to receive emails with MailSlurp.

See the [Email Model Specification](/docs/api/) for available properties and content for emails. See the [attachments guide](/guides/email-attachments-api/) for help with attachments.

### 1) Email controller

[EmailControllerApi](/docs/api/) methods such as `getEmail` and `getEmailsPaginated` return existing emails and content from inboxes. Call the [`getEmailsPaginated`](/docs/api/) method to return a paginated list of existing emails inside your inboxes. Call the [`getEmail`](/docs/api/#getEmail) to fetch an individual email and content.

### 2) WaitFor controller

[WaitForControllerApi](/docs/api/) methods such as `waitForLastestEmail` hold a connection open until conditions are met - such as a new email arriving. Use wait for methods in code or tests to perform actions and then test expected emails. Here is a example using the Ruby SDK:

```ruby
wait_controller = MailSlurpClient::WaitForControllerApi.new

# wait for email to arrive
email = wait_controller.wait_for_latest_email({ inbox_id: inbox.id, unread_only: true, timeout: 30_000 })

# assert the email is a confirmation
expect(email.subject).to include("Please confirm your email address")

# extract a 6 digit code from the email body
match = email.body.match(/code is ([0-9]{6})/)
if match == nil then
  raise "Could not find match in body #{email.body}"
end
code, * = match.captures
```

Use `unreadOnly=true` to ensure only new emails are returned. See the [receiving emails guide](/guides/receiving-emails/) for more information.

### 3)
