### Send Setup Instructions Request Body Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md JSON payload to trigger sending setup instructions to a specified email address. ```json { "email": "admin@example.com" } ``` -------------------------------- ### Retrieve a contact Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Example usage of the get method to fetch contact details by email. ```ruby contact = api.get('user@example.com') puts contact.email puts contact.status # 'subscribed' or 'unsubscribed' puts contact.fields # Custom fields hash ``` -------------------------------- ### Install Mailtrap Gem Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/README.md Add the gem to your Gemfile or install it via command line. ```ruby gem 'mailtrap' ``` ```bash $ bundle install ``` ```bash $ gem install mailtrap ``` -------------------------------- ### POST /accounts/{account_id}/sending_domains/{domain_id}/send_setup_instructions Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Send setup instructions for a domain to an email address. ```APIDOC ## POST https://mailtrap.io/api/accounts/{account_id}/sending_domains/{domain_id}/send_setup_instructions ### Description Sends domain setup instructions to the specified email address. ### Method POST ### Endpoint https://mailtrap.io/api/accounts/{account_id}/sending_domains/{domain_id}/send_setup_instructions ### Request Body - **email** (string) - Required - The email address to receive instructions. ``` -------------------------------- ### Create Project JSON Body Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Example request body for creating a new project. ```json { "project": { "name": "My Project" } } ``` -------------------------------- ### Create a contact Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Example usage of the create method with email, custom fields, and list IDs. ```ruby contact = api.create( email: 'newuser@example.com', fields: { 'first_name' => 'Alice', 'company' => 'ACME' }, list_ids: [101, 102] ) puts contact.newly_created? # true if newly created, false if already existed puts contact.id # UUID ``` -------------------------------- ### Create mail from template Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/mail.md Example usage of the from_template factory method. ```ruby mail = Mailtrap::Mail.from_template( from: { email: 'sender@example.com' }, to: [{ email: 'user@example.com', name: 'John' }], template_uuid: '2f45b0aa-bbed-432f-95e4-e145e1965ba2', template_variables: { 'user_name' => 'John Doe', 'reset_url' => 'https://...' } ) ``` -------------------------------- ### Instantiate WebhooksAPI Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Example of creating a new instance of the WebhooksAPI with a specific account ID. ```ruby api = Mailtrap::WebhooksAPI.new(account_id: 123) ``` -------------------------------- ### Create mail from content Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/mail.md Example usage of the from_content factory method. ```ruby mail = Mailtrap::Mail.from_content( from: { email: 'sender@example.com', name: 'Sender' }, to: [{ email: 'recipient@example.com', name: 'Recipient' }], subject: 'Hello World', text: 'This is a test email.', html: '

This is a test email.

', category: 'transactional' ) ``` -------------------------------- ### Instantiate ContactsAPI Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Example of creating a new ContactsAPI instance with a specific account ID and client configuration. ```ruby api = Mailtrap::ContactsAPI.new( account_id: 123, client: Mailtrap::Client.new(api_key: 'your-key') ) ``` -------------------------------- ### get(path, query_params = {}) Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/client.md Performs an HTTP GET request to the specified path with optional query parameters. ```APIDOC ## get(path, query_params = {}) ### Description Performs an HTTP GET request to the specified path. Returns a parsed JSON response or the raw body. ### Parameters - **path** (String) - Required - Request path (e.g., /api/accounts/123/contacts) - **query_params** (Hash) - Optional - Query parameters as key-value pairs (Default: {}) ``` -------------------------------- ### Perform HTTP GET request Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/client.md Executes a GET request to the specified path with optional query parameters. ```ruby def get(path, query_params = {}) ``` -------------------------------- ### Configure Environment-Specific Mailtrap Settings Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/configuration.md Examples for setting up Mailtrap in development, staging, and production environments. ```ruby # config/environments/development.rb config.action_mailer.delivery_method = :mailtrap config.action_mailer.mailtrap_settings = { api_key: ENV['MAILTRAP_API_KEY'], sandbox: true, inbox_id: ENV['MAILTRAP_INBOX_ID'].to_i } ``` ```ruby # config/environments/staging.rb config.action_mailer.delivery_method = :mailtrap config.action_mailer.mailtrap_settings = { api_key: ENV['MAILTRAP_API_KEY'] } ``` ```ruby # config/environments/production.rb config.action_mailer.delivery_method = :mailtrap config.action_mailer.mailtrap_settings = { api_key: ENV['MAILTRAP_API_KEY'] } # Register bulk delivery method ActionMailer::Base.add_delivery_method :mailtrap_bulk, Mailtrap::ActionMailer::DeliveryMethod config.action_mailer.mailtrap_bulk_settings = { api_key: ENV['MAILTRAP_BULK_API_KEY'], bulk: true } ``` -------------------------------- ### Define get method Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Method signature for retrieving a contact. ```ruby def get(contact_id) ``` -------------------------------- ### Create batch base from content Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/mail.md Example usage of batch_base_from_content to define shared properties for batch sending. ```ruby base = Mailtrap::Mail.batch_base_from_content( from: { email: 'notification@example.com' }, subject: 'Order Confirmation', text: 'Thank you for your order.' ) client.send_batch(base, [ Mailtrap::Mail.from_content(to: [{ email: 'user1@example.com' }]), Mailtrap::Mail.from_content(to: [{ email: 'user2@example.com' }]) ]) ``` -------------------------------- ### Send a single email Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/client.md Example of constructing a mail object and sending it via the client. ```ruby mail = Mailtrap::Mail.from_content( from: { email: 'sender@example.com', name: 'Sender' }, to: [{ email: 'recipient@example.com' }], subject: 'Hello', text: 'Email body' ) response = client.send(mail) puts response[:message_ids] # Array of sent message IDs ``` -------------------------------- ### Delete a contact Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Example usage of the delete method. ```ruby api.delete('user@example.com') ``` -------------------------------- ### Add contact to lists Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Example usage of the add_to_lists method. ```ruby contact = api.add_to_lists('user@example.com', [101, 102]) puts contact.list_ids # [101, 102] ``` -------------------------------- ### SandboxMessagesAPI#get Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/additional-apis.md Retrieves full details for a specific sandbox message. ```APIDOC ## SandboxMessagesAPI#get(project_id, inbox_id, message_id) ### Description Retrieves a specific sandbox message with full details. ### Parameters - **project_id** (Integer) - Required - The ID of the project. - **inbox_id** (Integer) - Required - The ID of the inbox. - **message_id** (Integer) - Required - The ID of the message. ### Returns - **SandboxMessage** - The requested message object. ``` -------------------------------- ### Define date filters Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/email-logs-api.md Example of using ISO 8601 string values for date-based filtering. ```ruby filters: { sent_after: "2025-01-01T00:00:00Z", sent_before: "2025-01-31T23:59:59Z" } ``` -------------------------------- ### GET /api/accounts/{account_id}/projects Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Lists all projects within a specific account. ```APIDOC ## GET /api/accounts/{account_id}/projects ### Description Lists all projects within a specific account. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/projects ### Parameters #### Path Parameters - **account_id** (Integer) - Required - The ID of the account ``` -------------------------------- ### Non-Exception Scenarios Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/errors.md Examples of API calls that return values instead of raising exceptions. ```ruby # These don't raise: api.delete(id) # Returns nil Mailtrap::Webhooks.verify_signature(...) # Returns true/false api.list # Returns [] if no items ``` -------------------------------- ### BillingAPI#get Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/additional-apis.md Retrieves current billing account information and usage statistics. ```APIDOC ## BillingAPI#get ### Description Returns current billing account information and usage. ### Returns - **BillingUsage** (Object) - Contains email_credits_used, email_credits_used_this_month, subscription_renewal_date, and current_plan_name. ``` -------------------------------- ### Access Gem Version Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/configuration.md Methods for checking the installed version of the Mailtrap gem. ```ruby Mailtrap::VERSION # => '2.11.1' ``` ```ruby require 'mailtrap/version' puts Mailtrap::VERSION ``` -------------------------------- ### Upsert a contact Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Example usage of the upsert method to update custom fields and subscription status. ```ruby contact = api.upsert( 'user@example.com', fields: { 'company' => 'NewCorp' }, unsubscribed: false ) ``` -------------------------------- ### Define get method signature Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/email-logs-api.md Method signature for fetching a single email log message. ```ruby def get(sending_message_id) ``` -------------------------------- ### Retrieve Aggregate Stats with Ruby Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Example of using the Mailtrap Ruby client to fetch aggregate statistics for a specific account within a date range. ```ruby api = Mailtrap::StatsAPI.new(account_id: 123) stats = api.get(start_date: '2025-01-01', end_date: '2025-01-31') ``` -------------------------------- ### GET /accounts/{account_id}/contacts/{contact_id} Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Get details for a specific contact. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/contacts/{contact_id} ### Description Retrieves details for a specific contact using UUID or email address. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/contacts/{contact_id} ``` -------------------------------- ### GET /accounts/{account_id}/projects/{project_id}/inboxes/{inbox_id}/messages Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Lists sandbox messages for a specific inbox. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/projects/{project_id}/inboxes/{inbox_id}/messages ### Description Lists sandbox messages for a specific inbox. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/projects/{project_id}/inboxes/{inbox_id}/messages ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. - **project_id** (string) - Required - The unique identifier of the project. - **inbox_id** (string) - Required - The unique identifier of the inbox. ``` -------------------------------- ### GET /accounts/{account_id}/projects/{project_id}/inboxes/{inbox_id}/messages/{message_id} Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieves details for a specific sandbox message. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/projects/{project_id}/inboxes/{inbox_id}/messages/{message_id} ### Description Retrieves details for a specific sandbox message. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/projects/{project_id}/inboxes/{inbox_id}/messages/{message_id} ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. - **project_id** (string) - Required - The unique identifier of the project. - **inbox_id** (string) - Required - The unique identifier of the inbox. - **message_id** (string) - Required - The unique identifier of the message. ``` -------------------------------- ### Mailtrap::Client.new Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/client.md Initializes a new Mailtrap::Client instance with configuration for API access, including authentication and host selection. ```APIDOC ## Mailtrap::Client.new ### Description Initializes a new Mailtrap::Client instance with configuration for API access. It handles authentication and sets the appropriate API host based on the provided flags. ### Parameters - **api_key** (String) - Required - API key for authentication. Defaults to ENV['MAILTRAP_API_KEY']. - **api_host** (String) - Optional - Custom API hostname. Auto-selected based on bulk and sandbox flags if not provided. - **general_api_host** (String) - Optional - Hostname for general API (non-sending) operations. Defaults to 'mailtrap.io'. - **api_port** (Integer) - Optional - Port number for API connections. Defaults to 443. - **bulk** (Boolean) - Optional - Use bulk sending API. Incompatible with sandbox: true. - **sandbox** (Boolean) - Optional - Use sandbox API for testing. Requires inbox_id. - **inbox_id** (Integer) - Conditional - Required if sandbox: true. ### Raises - ArgumentError: If api_key is nil, api_port is nil, bulk and sandbox are both true, or sandbox is true but inbox_id is nil. ### Example ```ruby client = Mailtrap::Client.new(api_key: 'your-api-key', sandbox: true, inbox_id: 12345) ``` ``` -------------------------------- ### create(options) Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Creates a new webhook configuration. ```APIDOC ## create(options) ### Description Creates a new webhook. ### Parameters - **options** (Hash) - Required - Webhook configuration - **options[:url]** (String) - Required - HTTPS endpoint URL - **options[:webhook_type]** (String) - Required - 'email_sending' or 'audit_log' - **options[:active]** (Boolean) - Optional - Enable immediately (default: true) - **options[:payload_format]** (String) - Optional - 'json' or 'jsonlines' (default: json) - **options[:sending_stream]** (String) - Conditional - Required for 'email_sending': 'transactional' or 'bulk' - **options[:event_types]** (Array) - Conditional - Required for 'email_sending' - **options[:domain_id]** (Integer) - Optional - Scope webhook to specific domain ### Returns - **Webhook** - Created webhook with signing_secret included ``` -------------------------------- ### Send Email via Mailer Class Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/action-mailer.md Example of sending an email using a standard Rails mailer class. ```ruby # In your mailer class class UserMailer < ApplicationMailer def welcome_email(user) @user = user mail(to: user.email, subject: 'Welcome to our app') end end # Send the email UserMailer.welcome_email(user).deliver_later # or synchronously: UserMailer.welcome_email(user).deliver_now ``` -------------------------------- ### Initialize Mailtrap::Client Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/client.md Constructor signature for configuring the client instance. ```ruby def initialize( api_key: ENV.fetch('MAILTRAP_API_KEY'), api_host: nil, general_api_host: GENERAL_API_HOST, api_port: API_PORT, bulk: false, sandbox: false, inbox_id: nil ) ``` -------------------------------- ### get(webhook_id) Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Retrieves a specific webhook by its ID. ```APIDOC ## get(webhook_id) ### Description Retrieves a specific webhook. ### Parameters - **webhook_id** (Integer) - Required - Webhook ID ### Returns - **Webhook** - Webhook object ### Example ```ruby webhook = api.get(456) ``` ``` -------------------------------- ### GET /accounts/{account_id}/contacts Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md List contacts for an account. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/contacts ### Description Retrieves a list of contacts for the account. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/contacts ### Parameters #### Query Parameters - **page** (integer) - Optional - Pagination page number. ``` -------------------------------- ### Initialize API Instance Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/configuration.md Standard initialization pattern for most API classes using account ID and client configuration. ```ruby API = Mailtrap::SomeAPI.new( account_id: ENV['MAILTRAP_ACCOUNT_ID'], # or explicit integer client: Mailtrap::Client.new # or custom client ) ``` -------------------------------- ### GET /api/accounts Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieves a list of all accounts associated with the user. ```APIDOC ## GET /api/accounts ### Description Retrieves a list of all accounts associated with the user. ### Method GET ### Endpoint https://mailtrap.io/api/accounts ### Response #### Success Response (200) - **id** (Integer) - Account ID - **name** (String) - Account name - **access_levels** (Array) - Permissions ``` -------------------------------- ### Verify Webhook Signature in Rails Controller Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Example implementation for verifying a webhook signature within a Rails controller, ensuring the raw request body is used. ```ruby # In your Rails controller post '/webhooks/mailtrap' do payload = request.body.read # Capture raw body exactly as received signature = request.headers['Mailtrap-Signature'] signing_secret = 'your-webhook-signing-secret' unless Mailtrap::Webhooks.verify_signature( payload: payload, signature: signature, signing_secret: signing_secret ) return [401, { error: 'Invalid signature' }.to_json] end # Signature verified, now parse the JSON event = JSON.parse(payload) process_webhook(event) [200, { success: true }.to_json] end ``` -------------------------------- ### Initialize Mailtrap Client for Production Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/README.md Configure the client for standard transactional email delivery using a verified domain. ```ruby client = Mailtrap::Client.new(api_key: 'your-key') client.send(mail) ``` -------------------------------- ### Remove contact from lists Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Example usage of the remove_from_lists method. ```ruby contact = api.remove_from_lists('user@example.com', [101]) ``` -------------------------------- ### Initialize Mailtrap Client with Environment Variables Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/configuration.md Instantiate the client and API classes to automatically read configuration from the environment. ```ruby # Reads from environment automatically client = Mailtrap::Client.new api = Mailtrap::ContactsAPI.new ``` -------------------------------- ### Initialize Production Transactional Client Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/client.md Creates a client instance configured for standard transactional email sending. ```ruby client = Mailtrap::Client.new(api_key: 'your-api-key') # Uses SENDING_API_HOST by default ``` -------------------------------- ### Get a specific webhook Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Retrieves details for a single webhook by its ID. ```ruby def get(webhook_id) ``` ```ruby webhook = api.get(456) puts webhook.url puts webhook.signing_secret # HMAC secret for verification ``` -------------------------------- ### Initialize Bulk API Client Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/client.md Creates a client instance configured for bulk email operations. ```ruby client = Mailtrap::Client.new(api_key: 'your-api-key', bulk: true) # Uses BULK_SENDING_API_HOST ``` -------------------------------- ### Mailtrap::Mail::Base#initialize Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/mail.md Constructor for creating a new mail object with specified email parameters. ```APIDOC ## Mailtrap::Mail::Base#initialize ### Description Initializes a new mail object instance with fields for sender, recipients, content, and template configuration. ### Parameters - **from** (Hash | nil) - Optional - Sender address: { email: 'user@example.com', name: 'Display Name' } - **to** (Array) - Optional - Recipient addresses as array of email/name objects - **reply_to** (Hash | nil) - Optional - Reply-to address - **cc** (Array) - Optional - Carbon copy recipients - **bcc** (Array) - Optional - Blind carbon copy recipients - **subject** (String | nil) - Optional - Email subject line - **text** (String | nil) - Optional - Plain text email body - **html** (String | nil) - Optional - HTML email body - **attachments** (Array) - Optional - File attachments - **headers** (Hash) - Optional - Custom email headers - **custom_variables** (Hash) - Optional - Custom variables for dynamic content - **category** (String | nil) - Optional - Email category/tag for grouping - **template_uuid** (String | nil) - Optional - UUID of pre-defined Mailtrap template - **template_variables** (Hash) - Optional - Variables to inject into template ``` -------------------------------- ### get(contact_id) Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Retrieves a specific contact by ID or email address. ```APIDOC ## get(contact_id) ### Description Retrieves a specific contact by ID or email address. ### Parameters - **contact_id** (String) - Required - Contact UUID or email address ### Returns - **Contact** - Contact object ### Example ```ruby contact = api.get('user@example.com') puts contact.email puts contact.status puts contact.fields ``` ``` -------------------------------- ### Complete Contact Management Workflow in Ruby Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Demonstrates the full lifecycle of a contact including creation, retrieval, updating fields, list management, and deletion. ```ruby api = Mailtrap::ContactsAPI.new(account_id: 123) # Create a new contact contact = api.create( email: 'alice@example.com', fields: { 'first_name' => 'Alice', 'last_name' => 'Smith', 'phone' => '+1-555-123-4567' }, list_ids: [1, 2] ) puts "Created contact: #{contact.id}" puts "Newly created: #{contact.newly_created?}" # Retrieve the contact retrieved = api.get(contact.id) puts "Email: #{retrieved.email}" puts "Lists: #{retrieved.list_ids}" # Update custom fields updated = api.upsert( contact.id, fields: { 'company' => 'TechCorp' } ) # Add to additional lists api.add_to_lists(contact.id, [3, 4]) # Remove from a list api.remove_from_lists(contact.id, [2]) # Delete api.delete(contact.id) ``` -------------------------------- ### List Projects with Ruby Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Fetches projects for a specific account ID. ```ruby api = Mailtrap::ProjectsAPI.new(account_id: 123) api.list ``` -------------------------------- ### Initialize Mailtrap Client for Development Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/README.md Configure the client with sandbox mode enabled to route emails to a specific test inbox. ```ruby client = Mailtrap::Client.new( api_key: 'your-key', sandbox: true, inbox_id: 12345 ) # All emails go to test inbox, visible in Mailtrap web UI client.send(mail) ``` -------------------------------- ### GET /accounts/{account_id}/suppressions/{suppression_id} Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieves details for a specific suppression. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/suppressions/{suppression_id} ### Description Retrieves details for a specific suppression. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/suppressions/{suppression_id} ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. - **suppression_id** (string) - Required - The unique identifier of the suppression. ``` -------------------------------- ### GET https://mailtrap.io/api/accounts/{account_id}/stats Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieve aggregate sending statistics. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/stats ### Description Retrieves aggregate statistics for email sending, with optional filtering and grouping. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/stats ### Parameters #### Query Parameters - **start_date** (string) - Optional - ISO 8601 start date. - **end_date** (string) - Optional - ISO 8601 end date. - **sending_domain_ids[]** (array) - Optional - Filter by domain IDs. - **sending_streams[]** (array) - Optional - Filter by stream. - **categories[]** (array) - Optional - Filter by category. - **email_service_providers[]** (array) - Optional - Filter by ESP. - **grouping** (string) - Optional - Grouping criteria (domains, categories, email_service_providers, date). ``` -------------------------------- ### Initialize Sandbox Testing Client Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/client.md Creates a client instance for sandbox testing, requiring an inbox_id. ```ruby client = Mailtrap::Client.new( api_key: 'your-api-key', sandbox: true, inbox_id: 12345 ) # Uses SANDBOX_API_HOST with inbox ID ``` -------------------------------- ### GET https://mailtrap.io/api/accounts/{account_id}/webhooks Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Lists all webhooks configured for the account. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/webhooks ### Description Retrieves a list of all webhooks configured for the specified account. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/webhooks ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. ``` -------------------------------- ### Initialize ContactsAPI Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Constructor signature for the ContactsAPI class. ```ruby def initialize( account_id = ENV.fetch('MAILTRAP_ACCOUNT_ID'), client = Mailtrap::Client.new ) ``` -------------------------------- ### List Contacts with Ruby Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Initializes the ContactsAPI client for a specific account and retrieves the first page of contacts. ```ruby api = Mailtrap::ContactsAPI.new(account_id: 123) api.list # Returns first page ``` -------------------------------- ### GET /accounts/{account_id}/suppressions Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Lists suppressions for an account, with optional filtering and pagination. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/suppressions ### Description Lists suppressions for an account, with optional filtering and pagination. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/suppressions ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. #### Query Parameters - **status** (string) - Optional - Filter by status (unsubscribed, complained, bounced). - **search_after** (string) - Optional - Pagination cursor. ``` -------------------------------- ### GET /accounts/{account_id}/contact_lists/{list_id} Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieves details for a specific contact list. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/contact_lists/{list_id} ### Description Retrieves details for a specific contact list. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/contact_lists/{list_id} ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. - **list_id** (string) - Required - The unique identifier of the contact list. ``` -------------------------------- ### Initialize Mail::Base Object Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/mail.md Constructor signature for creating a new mail object with various email parameters. ```ruby def initialize( from: nil, to: [], reply_to: nil, cc: [], bcc: [], subject: nil, text: nil, html: nil, attachments: [], headers: {}, custom_variables: {}, category: nil, template_uuid: nil, template_variables: {} ) ``` -------------------------------- ### GET https://mailtrap.io/api/accounts/{account_id}/email_templates Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md List all email templates for a specific account. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/email_templates ### Description Retrieves a list of all email templates associated with the specified account. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/email_templates ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. ``` -------------------------------- ### Get Email Log Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Fetches details for a specific email log message by its ID. ```ruby message = api.get('550e8400-e29b-41d4-a716-446655440000') ``` -------------------------------- ### API Initialization Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/configuration.md Standard pattern for initializing Mailtrap API classes using a shared client. ```APIDOC ## Mailtrap::API Initialization ### Description Most API classes require an `account_id` and a `Mailtrap::Client` instance for initialization. ### Parameters - **account_id** (Integer) - Required - The ID of the account to perform operations on. - **client** (Mailtrap::Client) - Required - The configured API client instance. ### Example ```ruby client = Mailtrap::Client.new(api_key: 'YOUR_API_KEY') api = Mailtrap::ContactsAPI.new(account_id: 123, client: client) ``` ``` -------------------------------- ### GET /accounts/{account_id}/sending_domains/{domain_id} Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieve details for a specific sending domain. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/sending_domains/{domain_id} ### Description Retrieves details for a specific sending domain. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/sending_domains/{domain_id} ### Parameters #### Path Parameters - **account_id** (integer) - Required - The unique identifier of the account. - **domain_id** (integer) - Required - The unique identifier of the domain. ``` -------------------------------- ### create(options) Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Creates a new contact. ```APIDOC ## create(options) ### Description Creates a new contact. ### Parameters - **options** (Hash) - Required - Contact attributes - **options[:email]** (String) - Required - Email address - **options[:fields]** (Hash) - Optional - Custom fields object - **options[:list_ids]** (Array) - Optional - List IDs to add contact to ### Returns - **Contact** - Created contact object ### Example ```ruby contact = api.create( email: 'newuser@example.com', fields: { 'first_name' => 'Alice', 'company' => 'ACME' }, list_ids: [101, 102] ) ``` ``` -------------------------------- ### Configure Mailtrap Environment Settings Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/action-mailer.md Set up Mailtrap delivery method and settings in environment files. ```ruby config.action_mailer.delivery_method = :mailtrap config.action_mailer.mailtrap_settings = { api_key: 'your-api-key' # Or use MAILTRAP_API_KEY env var } ``` ```ruby config.action_mailer.delivery_method = :mailtrap config.action_mailer.mailtrap_settings = { api_key: 'your-api-key', sandbox: true, inbox_id: 12345 } ``` ```ruby config.action_mailer.delivery_method = :mailtrap config.action_mailer.mailtrap_settings = { api_key: 'your-api-key', bulk: true } ``` -------------------------------- ### GET /accounts/{account_id}/sending_domains Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md List all sending domains associated with the specified account. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/sending_domains ### Description Retrieves a list of all sending domains for a given account. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/sending_domains ### Parameters #### Path Parameters - **account_id** (integer) - Required - The unique identifier of the account. ``` -------------------------------- ### Send basic email with Mailtrap Ruby Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/README.md Initializes the client and sends a simple email using the Mailtrap::Client and Mailtrap::Mail classes. ```ruby require 'mailtrap' client = Mailtrap::Client.new(api_key: 'your-api-key') mail = Mailtrap::Mail.from_content( from: { email: 'sender@example.com', name: 'Sender' }, to: [{ email: 'recipient@example.com', name: 'Recipient' }], subject: 'Hello World', text: 'This is a test email.' ) response = client.send(mail) puts response[:message_ids] ``` -------------------------------- ### Mailtrap::WebhooksAPI Constructor Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Initializes a new instance of the WebhooksAPI client to interact with Mailtrap webhook settings. ```APIDOC ## Mailtrap::WebhooksAPI.new ### Description Initializes the WebhooksAPI client with an account ID and an optional pre-configured client. ### Parameters - **account_id** (Integer | String) - Required - Mailtrap account ID - **client** (Mailtrap::Client) - Optional - Pre-configured client instance ### Example ```ruby api = Mailtrap::WebhooksAPI.new(account_id: 123) ``` ``` -------------------------------- ### AccountsAPI Initialization Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/configuration.md AccountsAPI is a special case that does not require an account_id parameter. ```ruby api = Mailtrap::AccountsAPI.new(client: client) accounts = api.list # Lists all accounts ``` -------------------------------- ### Instantiate EmailLogsAPI Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/email-logs-api.md Creates a new instance of the EmailLogsAPI with a specified account ID. ```ruby api = Mailtrap::EmailLogsAPI.new(account_id: 123) ``` -------------------------------- ### AccountsAPI Initialization Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/configuration.md Special initialization case for the AccountsAPI which does not require an account_id. ```APIDOC ## Mailtrap::AccountsAPI Initialization ### Description The AccountsAPI is used to list all accounts and does not require an `account_id` parameter. ### Parameters - **client** (Mailtrap::Client) - Required - The configured API client instance. ### Example ```ruby api = Mailtrap::AccountsAPI.new(client: client) accounts = api.list ``` ``` -------------------------------- ### GET /accounts/{account_id}/contact_lists Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieves a list of all contact lists associated with the specified account. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/contact_lists ### Description Retrieves a list of all contact lists associated with the specified account. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/contact_lists ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. ``` -------------------------------- ### List and Manage Webhooks Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Retrieves all existing webhooks and demonstrates how to update or delete a specific webhook by ID. ```ruby api = Mailtrap::WebhooksAPI.new(account_id: 123) # Get all webhooks api.list.each do |w| puts "ID: #{w.id}, Type: #{w.webhook_type}, URL: #{w.url}, Active: #{w.active}" end # Update webhook api.update(webhook_id, active: false) # Delete webhook api.delete(webhook_id) ``` -------------------------------- ### GET https://mailtrap.io/api/accounts/{account_id}/email_templates/{template_id} Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieve details for a specific email template. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/email_templates/{template_id} ### Description Retrieves the details of a specific email template by its ID. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/email_templates/{template_id} ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. - **template_id** (string) - Required - The unique identifier of the template. ``` -------------------------------- ### Define operator-based filters Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/email-logs-api.md Example of using operator-value pairs for filtering email log fields. ```ruby filters: { to: { operator: "ci_equal", value: "recipient@example.com" }, status: { operator: "equal", value: "delivered" }, category: { operator: "equal", value: ["Welcome", "Transactional"] } # Array for multi-value } ``` -------------------------------- ### List Sending Domains with Ruby Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Initializes the SendingDomainsAPI client for a specific account and retrieves the list of domains. ```ruby api = Mailtrap::SendingDomainsAPI.new(account_id: 123) api.list ``` -------------------------------- ### Setting Environment Variables Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/action-mailer.md Configures API credentials and inbox settings via shell environment variables. ```bash export MAILTRAP_API_KEY="your-api-key" export MAILTRAP_INBOX_ID="12345" ``` -------------------------------- ### Define Project Struct Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/types.md Represents a sandbox project containing multiple inboxes. ```ruby Project = Struct.new( :id, :name, :share_links, :inboxes, :permissions, keyword_init: true ) ``` -------------------------------- ### Mailtrap::EmailLogsAPI.new Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/email-logs-api.md Initializes a new instance of the EmailLogsAPI to interact with email log data for a specific account. ```APIDOC ## Mailtrap::EmailLogsAPI.new ### Description Initializes a new instance of the EmailLogsAPI class. This class is used to retrieve detailed information about sent emails. ### Parameters - **account_id** (Integer | String) - Required - Mailtrap account ID. Defaults to ENV['MAILTRAP_ACCOUNT_ID']. - **client** (Mailtrap::Client) - Optional - Pre-configured client instance. Defaults to a new Mailtrap::Client. ### Example ```ruby api = Mailtrap::EmailLogsAPI.new(account_id: 123) ``` ``` -------------------------------- ### GET https://mailtrap.io/api/accounts/{account_id}/billing/usage Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieves the current billing usage information for a specific account. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/billing/usage ### Description Fetches the billing usage statistics for the specified account. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/billing/usage ``` -------------------------------- ### Send a simple email with Ruby Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/mail.md Constructs and sends an email using raw text and HTML content. ```ruby mail = Mailtrap::Mail.from_content( from: { email: 'sender@example.com', name: 'Company' }, to: [{ email: 'customer@example.com' }], subject: 'Welcome to our service', text: 'Welcome aboard!', html: '

Welcome

We are excited to have you.

' ) client = Mailtrap::Client.new(api_key: 'your-key') response = client.send(mail) ``` -------------------------------- ### Webhook Configuration Options Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Supported configuration options for creating or updating webhooks. ```APIDOC ## Webhook Configuration Options ### Options - **:url** (String) - Required for create/update - Webhook endpoint URL (must be HTTPS) - **:webhook_type** (String) - Required for create - Type: 'email_sending' or 'audit_log' - **:active** (Boolean) - Optional - Whether webhook is active (default: true) - **:payload_format** (String) - Optional - 'json' or 'jsonlines' (default: json) - **:sending_stream** (String) - Required for email_sending - 'transactional' or 'bulk' - **:event_types** (Array) - Required for email_sending - Event types to subscribe to - **:domain_id** (Integer) - Optional - Optional domain ID to scope webhook (email_sending only) ``` -------------------------------- ### Mailtrap::EmailLogsAPI#get Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/email-logs-api.md Retrieves the full details and event history for a specific email message by its ID. ```APIDOC ## Mailtrap::EmailLogsAPI#get ### Description Retrieves the full details and event history for a specific email message by its ID. ### Parameters - **message_id** (String) - Required - The unique identifier of the email message. ### Request Example ```ruby message = api.get('550e8400-e29b-41d4-a716-446655440000') ``` ``` -------------------------------- ### Define create method Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Method signature for creating a new contact. ```ruby def create(options) ``` -------------------------------- ### Create a new webhook Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Creates a new webhook configuration. Requires specific options based on the webhook type. ```ruby def create(options) ``` ```ruby webhook = api.create( url: 'https://example.com/webhooks/mailtrap', webhook_type: 'email_sending', sending_stream: 'transactional', event_types: ['sent', 'delivered', 'opened', 'clicked', 'bounced'] ) puts "Webhook ID: #{webhook.id}" puts "Signing secret: #{webhook.signing_secret}" # Store securely! ``` -------------------------------- ### Server Error Response Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/errors.md Example of JSON error array returned for HTTP 5xx status codes. ```json ["server error"] ``` -------------------------------- ### Size Error Responses Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/errors.md Examples of JSON error arrays returned for HTTP 413 status codes. ```json ["message too large"] ["Batch request exceeds maximum size"] ``` -------------------------------- ### ProjectsAPI Methods Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/additional-apis.md CRUD operations for sandbox projects including listing, retrieving, creating, updating, and deleting projects. ```APIDOC ## ProjectsAPI Methods ### list Returns all projects for the account. ### get(project_id) Retrieves a specific project with its inboxes. - **project_id** (Integer) - Required ### create(options) Creates a new project. - **options[:name]** (String) - Required ### update(project_id, options) Updates a project. - **project_id** (Integer) - Required - **options[:name]** (String) - Optional ### delete(project_id) Deletes a project. - **project_id** (Integer) - Required ### Project Structure - **id** (Integer) - **name** (String) - **share_links** (Hash) - **inboxes** (Array) - **permissions** (Hash) ``` -------------------------------- ### Rejection Error Responses Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/errors.md Examples of JSON error arrays returned for HTTP 403 status codes. ```json ["Account is banned"] ["Domain is not verified. Please verify your domain."] ["Insufficient credits"] ["Sender is not allowed"] ``` -------------------------------- ### Basic Rails Mailer Implementation Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/action-mailer.md Defines a standard Rails mailer class and demonstrates how to trigger delivery. ```ruby class NotificationMailer < ApplicationMailer def send_notification(user, notification) @user = user @notification = notification mail( to: user.email, subject: "You have a new notification" ) end end # app/views/notification_mailer/send_notification.html.erb

Hi <%= @user.name %>

<%= @notification.message %>

# In your application code NotificationMailer.send_notification(user, notification).deliver_now ``` -------------------------------- ### Authorization Error Responses Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/errors.md Examples of JSON error arrays returned for HTTP 401 status codes. ```json ["Invalid API key"] ["API key has been revoked"] ["Unauthorized"] ``` -------------------------------- ### POST /api/accounts/{account_id}/projects Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Creates a new project within the specified account. ```APIDOC ## POST /api/accounts/{account_id}/projects ### Description Creates a new project within the specified account. ### Method POST ### Endpoint https://mailtrap.io/api/accounts/{account_id}/projects ### Parameters #### Path Parameters - **account_id** (Integer) - Required - The ID of the account #### Request Body - **project** (Object) - Required - Project details ### Request Example { "project": { "name": "My Project" } } ``` -------------------------------- ### List email logs with pagination Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/email-logs-api.md Retrieves a page of logs and demonstrates how to use the next_page_cursor for subsequent requests. ```ruby api = Mailtrap::EmailLogsAPI.new(account_id: 123) # Get first page response = api.list( filters: { sent_after: "2025-01-01T00:00:00Z", sent_before: "2025-01-31T23:59:59Z", to: { operator: "ci_equal", value: "recipient@example.com" }, status: { operator: "equal", value: "delivered" } } ) puts "Total messages: #{response.total_count}" puts "Messages on this page: #{response.messages.length}" # Get next page if available if response.next_page_cursor next_response = api.list( filters: filters, search_after: response.next_page_cursor ) end ``` -------------------------------- ### Validation Error Responses Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/errors.md Examples of JSON error arrays returned for HTTP 400 status codes. ```json ["Email is invalid"] ["Domain does not belong to this account"] ["Contact not found"] ["Invalid filter option: unknown_field"] ``` -------------------------------- ### Define batch_base_from_content method Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/mail.md Method signature for creating a base mail object for batch sending with explicit content. ```ruby def self.batch_base_from_content( from: nil, reply_to: nil, attachments: [], headers: {}, custom_variables: {}, subject: nil, text: nil, html: nil, category: nil ) ``` -------------------------------- ### list() Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/webhooks-api.md Retrieves all webhooks associated with the account. ```APIDOC ## list() ### Description Retrieves all webhooks for the account. ### Method Ruby SDK Method ### Returns - **Array** - Array of webhook objects ### Example ```ruby api = Mailtrap::WebhooksAPI.new(account_id: 123) webhooks = api.list ``` ``` -------------------------------- ### Define AccountsAPI list method Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/additional-apis.md Method signature for listing accounts. ```ruby def list ``` -------------------------------- ### GET https://mailtrap.io/api/accounts/{account_id}/email_logs/{message_id} Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-endpoints.md Retrieves the full details of a specific email log message. ```APIDOC ## GET https://mailtrap.io/api/accounts/{account_id}/email_logs/{message_id} ### Description Retrieves the full details of a specific email log message, including events and the raw message URL. ### Method GET ### Endpoint https://mailtrap.io/api/accounts/{account_id}/email_logs/{message_id} ### Parameters #### Path Parameters - **account_id** (string) - Required - The unique identifier of the account. - **message_id** (string) - Required - The unique identifier of the message. ### Response #### Success Response (200) - **EmailLogMessage** (object) - Full message details including events and raw_message_url. ``` -------------------------------- ### Define batch_base_from_template method Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/mail.md Method signature for creating a base mail object for batch sending using a template. ```ruby def self.batch_base_from_template( from: nil, reply_to: nil, attachments: [], headers: {}, custom_variables: {}, template_uuid: nil, template_variables: {} ) ``` -------------------------------- ### Rate Limit Error Responses Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/errors.md Examples of JSON error arrays returned for HTTP 429 status codes. ```json ["too many requests"] ["Rate limit exceeded"] ``` -------------------------------- ### Mailtrap::ContactsAPI Constructor Source: https://github.com/mailtrap/mailtrap-ruby/blob/main/_autodocs/api-reference/contacts-api.md Initializes a new instance of the ContactsAPI to interact with Mailtrap contact services. ```APIDOC ## Mailtrap::ContactsAPI.new ### Description Initializes a new ContactsAPI instance for managing email contacts. ### Parameters - **account_id** (Integer | String) - Required - Mailtrap account ID. Defaults to ENV['MAILTRAP_ACCOUNT_ID']. - **client** (Mailtrap::Client) - Optional - Pre-configured client instance. ### Raises - ArgumentError if account_id is nil ### Example ```ruby api = Mailtrap::ContactsAPI.new( account_id: 123, client: Mailtrap::Client.new(api_key: 'your-key') ) ``` ```