### Install and Setup MailerSend Ruby Client Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Install the gem and initialize the MailerSend client. The client can use an environment variable for the API token or accept it directly. It also exposes the underlying HTTP client for direct requests. ```ruby gem 'mailersend-ruby' # Terminal # gem install mailersend-ruby require "mailersend-ruby" # Initialize using environment variable MAILERSEND_API_TOKEN ms_client = Mailersend::Client.new # Or pass the token explicitly ms_client = Mailersend::Client.new('your_api_token_here') # The client exposes a pre-configured HTTP object (http gem) response = ms_client.http.get("https://api.mailersend.com/v1/api-quota") puts response.status # => 200 puts response.parse # => { "quota" => 1000, "remaining" => 998, ... } ``` -------------------------------- ### Install Mailersend Ruby Gem Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Install the Mailersend Ruby gem using the provided command. Ensure you require the library in your Ruby files. ```bash gem install mailersend-ruby ``` -------------------------------- ### Get templates Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of templates for a given domain, with pagination options. ```APIDOC ## Templates ### Get templates #### Description Retrieves a list of templates for a given domain, with pagination options. #### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_templates = Mailersend::Templates.new(ms_client) ms_templates.list(domain_id: "aax455lll", page: 1, limit: 10) ``` #### Parameters ##### Query Parameters - **domain_id** (string) - Required - The ID of the domain to list templates for. - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of items per page. ``` -------------------------------- ### Get DNS Records for a Domain Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Fetches the necessary DNS records for a given domain to verify its setup with Mailersend. Requires the domain ID and your API token. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_domains = Mailersend::Domains.new(ms_client) ms_domains.dns(domain_id: "idofdomain12412") ``` -------------------------------- ### Get a list of activities Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of activities for a given domain. ```APIDOC ## Activity ### Get a list of activities ### Description Retrieves a list of activities for a given domain, with options for pagination and date filtering. ### Method GET ### Endpoint /activity/{domain_id} ### Parameters #### Path Parameters - **domain_id** (string) - Required - The ID of the domain to retrieve activities for. #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of activities to return per page. - **date_from** (integer) - Optional - Unix timestamp for the start date. - **date_to** (integer) - Optional - Unix timestamp for the end date. ### Request Example ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_activity = Mailersend::Activity.new(ms_client) ms_activity.get(domain_id: "xxx2241ll", page: 3, limit: 5, date_from: 1620643567, date_to: 1623321967) ``` ``` -------------------------------- ### Get a Single Template Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Fetch details for a specific template using its ID. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_templates = Mailersend::Templates.new(ms_client) ms_templates.single(template_id: "id124") ``` -------------------------------- ### Get a list of domains Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of all domains associated with your account. ```APIDOC ## Domains ### Get a list of domains ### Description Retrieves a list of all email domains configured within your Mailersend account. ### Method GET ### Endpoint /domains ### Request Example ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_domains = Mailersend::Domains.new(ms_client) ms_domains.list ``` ``` -------------------------------- ### Get a single template Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific template using its ID. ```APIDOC ### Get a single template #### Description Retrieves details for a specific template using its ID. #### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_templates = Mailersend::Templates.new(ms_client) ms_templates.single(template_id: "id124") ``` #### Parameters ##### Query Parameters - **template_id** (string) - Required - The ID of the template to retrieve. ``` -------------------------------- ### Get a list of monitors Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of all DMARC monitors configured for your account. ```APIDOC ## Get a list of monitors ### Description Retrieves a list of all DMARC monitors configured for your account. ### Method ```ruby Mailersend::DmarcMonitoring.list ``` ### Parameters None ``` -------------------------------- ### Get a list of inbound routes Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of all configured inbound routes. ```APIDOC ## Inbound Routes ### Get a list of inbound routes ### Description Retrieves a list of all inbound routing rules configured for your account. ### Method GET ### Endpoint /inbound-routing ### Request Example ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_inbound_routes = Mailersend::InboundRouting.new(ms_client) ms_inbound_routes.get_inbound_routes ``` ``` -------------------------------- ### Get a list of sms activities Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of SMS activities. ```APIDOC ## SMS Activity ### Get a list of sms activities #### Description Retrieves a list of SMS activities. #### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') # Intialize the SMS Recipient class ms_sms_activity = Mailersend::SMSActivity.new(ms_client) # Add parameters # No parameters shown in the example for this method. ``` ``` -------------------------------- ### Run Tests - Bash Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Install project dependencies using Bundler and execute all tests using RSpec. This is essential for verifying the SDK's functionality. ```bash bundle i bundle exec rspec spec/*_rspec.rb ``` -------------------------------- ### Get a List of SMS Activities Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieve a list of SMS activities. Requires initialization of the SMSActivity class. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') # Intialize the SMS Recipient class ms_sms_activity = Mailersend::SMSActivity.new(ms_client) ``` -------------------------------- ### Get a webhook Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific webhook using its ID. ```APIDOC ## Get a webhook ### Description Retrieves details for a specific webhook using its ID. ### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_webhooks = Mailersend::Webhooks.new(ms_client) ms_webhooks.single(webhook_id: "zzz2241ll") ``` ### Parameters #### Query Parameters - **webhook_id** (string) - Required - The ID of the webhook to retrieve. ``` -------------------------------- ### Get Opens by Reading Environment Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md View email open statistics categorized by the type of reading environment (e.g., webmail, mobile client) within a date range. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_analytics = Mailersend::Analytics.new(ms_client) ms_analytics.ua_type(date_from: 1620643567, date_to: 1623321967) ``` -------------------------------- ### Manage Email Identities with Mailersend Ruby SDK Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Examples for adding, listing, fetching, updating, and deleting email identities. Ensure you have the correct domain ID for operations. ```ruby ms_identity.add( domain_id: "zr6ke4n7777893yw", name: "Alice Support", email: "alice@yourdomain.com", reply_to_email: "support@yourdomain.com", reply_to_name: "Support Team" ) ``` ```ruby ms_identity.list(domain_id: "zr6ke4n7777893yw", page: 1, limit: 10) ``` ```ruby ms_identity.single(identity_id: "identity_abc123") ``` ```ruby ms_identity.single_by_email(email: "alice@yourdomain.com") ``` ```ruby ms_identity.update(identity_id: "identity_abc123", reply_to_name: "Alice - Support") ``` ```ruby ms_identity.update_by_email(email: "alice@yourdomain.com", reply_to_name: "Alice - Support") ``` ```ruby ms_identity.delete(identity_id: "identity_abc123") ``` ```ruby ms_identity.delete_by_email(email: "alice@yourdomain.com") ``` -------------------------------- ### Get a single domain Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific domain using its ID. ```APIDOC ### Get a single domain ### Description Retrieves the configuration and status details for a specific email domain identified by its unique ID. ### Method GET ### Endpoint /domains/{domain_id} ### Parameters #### Path Parameters - **domain_id** (string) - Required - The ID of the domain to retrieve. ### Request Example ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_domains = Mailersend::Domains.new(ms_client) ms_domains.single(domain_id: "idofdomain12412") ``` ``` -------------------------------- ### Get API Quota Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md This snippet shows how to retrieve the current API quota information. ```APIDOC ## Get API Quota ### Description Retrieves the current usage of your Mailersend API quota. ### Method `get_api_quota` ### Parameters None ### Request Example ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_api_quota = Mailersend::APIQuota.new(ms_client) ms_api_quota.get_api_quota ``` ``` -------------------------------- ### Get Opens by Country Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieve email open statistics broken down by country for a given date range. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_analytics = Mailersend::Analytics.new(ms_client) ms_analytics.country(date_from: 1620643567, date_to: 1623321967) ``` -------------------------------- ### Get Single Domain Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Fetch details for a specific domain using its unique domain ID. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_domains = Mailersend::Domains.new(ms_client) ms_domains.single(domain_id: "idofdomain12412") ``` -------------------------------- ### Get Opens by User-Agent Name Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Analyze email open data based on the user-agent name for a specified period. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_analytics = Mailersend::Analytics.new(ms_client) ms_analytics.ua_name(date_from: 1620643567, date_to: 1623321967) ``` -------------------------------- ### Get List of Domains Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieve a list of all domains configured within your Mailersend account. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_domains = Mailersend::Domains.new(ms_client) ms_domains.list ``` -------------------------------- ### Get all email verification lists Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of all email verification lists, with pagination options. ```APIDOC ### Get all email verification lists #### Description Retrieves a list of all email verification lists, with pagination options. #### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_email_verification = Mailersend::EmailVerification.new(ms_client) ms_email_verification.list(page: 1, limit: 10) ``` #### Parameters ##### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of items per page. ``` -------------------------------- ### Get a List of DMARC Monitors Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of all configured DMARC monitors. Requires your Mailersend API token. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client) ms_dmarc.list ``` -------------------------------- ### Get API Quota Information Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Check your current API rate limit allocation and remaining request count. Requires initialization of Mailersend::Client and Mailersend::APIQuota. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_quota = Mailersend::APIQuota.new(ms_client) response = ms_quota.get_api_quota quota = response.parse puts "Quota limit: #{quota["quota"]}" puts "Quota remaining: #{quota["remaining"]}" ``` -------------------------------- ### Retrieve Email Opens by Country Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Use this to get email open statistics broken down by recipient country. Requires a domain ID and a date range. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_analytics = Mailersend::Analytics.new(ms_client) response = ms_analytics.country( date_from: Time.new(2024, 6, 1).to_i, date_to: Time.new(2024, 6, 30).to_i, domain_id: "zr6ke4n7777893yw" ) response.parse["data"]["stats"].each do |stat| puts "#{stat["name"]}: #{stat["count"]} opens" end ``` -------------------------------- ### Get a Single Email Verification List Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieve details for a specific email verification list using its ID. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_email_verification = Mailersend::EmailVerification.new(ms_client) ms_email_verification.get_single_list(email_verification_id: 'your-email-verification-id') ``` -------------------------------- ### Get API Quota - Ruby Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieve your current API quota usage. This helps in monitoring your API limits and understanding your usage patterns. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') # Intialize the API Quota class ms_api_quota = Mailersend::APIQuota.new(ms_client) # Add parameters ms_api_quota.get_api_quota ``` -------------------------------- ### Get Activity List Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieve a list of email activities for a specific domain. Supports pagination and date filtering. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_activity = Mailersend::Activity.new(ms_client) ms_activity.get(domain_id: "xxx2241ll", page: 3, limit: 5, date_from: 1620643567, date_to: 1623321967) ``` -------------------------------- ### Create and Verify Bulk Email List Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Create a bulk list for email verification and then initiate the verification process. This is useful for cleaning up large email lists before campaigns. Ensure the list name and emails are correctly provided. ```ruby # Create a bulk verification list create_resp = ms_email_verify.create_a_list( name: "June 2024 Campaign", emails: ["user1@example.com", "user2@example.com", "invalid@@bad"] ) list_id = create_resp.parse["data"]["id"] # Start verifying the list ms_email_verify.verify_a_list(email_verification_id: list_id) # Poll for results results_resp = ms_email_verify.get_list_results(email_verification_id: list_id) results_resp.parse["data"].each do |r| puts "#{r["email"]}: #{r["result"]}" end ``` -------------------------------- ### Get Analytics by Date Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Query aggregated email event counts grouped by day or hour for specified event types and a date range. Requires a date range, event types, domain ID, and grouping interval. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_analytics = Mailersend::Analytics.new(ms_client) response = ms_analytics.date( date_from: Time.new(2024, 6, 1).to_i, date_to: Time.new(2024, 6, 30).to_i, events: %w[queued sent delivered opened clicked bounced], domain_id: "zr6ke4n7777893yw", group_by: "days" ) response.parse["data"]["stats"].each do |stat| puts "#{stat["date"]}: sent=#{stat["sent"]}, opened=#{stat["opened"]}" end ``` -------------------------------- ### Create a token Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md This snippet demonstrates how to create a new API token with specified name, scopes, and domain. ```APIDOC ## Create a token ### Description Creates a new API token with specified permissions. ### Method `Mailersend::Tokens.create` ### Parameters - `name` (string): The name for the new token. - `scopes` (array of strings): An array of permissions for the token (e.g., `['email_full', 'domains_read']`). - `domain_id` (string): The ID of the domain this token is associated with. ### Request Example ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_tokens = Mailersend::Tokens.new(ms_client) ms_tokens.create(name: "Very nice token", scopes: %w[ email_full domains_read ], domain_id: "yourdomainid") ``` ``` -------------------------------- ### Get Recipients Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a paginated list of recipients. ```APIDOC ## Get Recipients ### Description Retrieves a paginated list of recipients. ### Method ```ruby ms_recipients.list(page: 1, limit: 10) ``` ### Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of items to return per page. ``` -------------------------------- ### Create a Webhook Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Create a new webhook to receive event notifications. Requires domain ID, URL, name, events, and enabled status. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_webhooks = Mailersend::Webhooks.new(ms_client) ms_webhooks.create(domain_id: "xxx2241ll", url: "https://domain.com/hook", name: "Webhook", events: ["activity.sent", "activity.delivered"], enabled: true) ``` -------------------------------- ### Get Recipients List Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a paginated list of recipients. You can specify the page number and the number of items per page. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_recipients = Mailersend::Recipients.new(ms_client) ms_recipients.list(page: 1, limit: 10) ``` -------------------------------- ### Create a webhook Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Creates a new webhook for a given domain with specified URL, name, events, and enabled status. ```APIDOC ## Create a webhook ### Description Creates a new webhook for a given domain with specified URL, name, events, and enabled status. ### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_webhooks = Mailersend::Webhooks.new(ms_client) ms_webhooks.create(domain_id: "xxx2241ll", url: "https://domain.com/hook", name: "Webhook", events: ["activity.sent", "activity.delivered"], enabled: true) ``` ### Parameters #### Request Body - **domain_id** (string) - Required - The ID of the domain for which to create the webhook. - **url** (string) - Required - The URL to which webhook events will be sent. - **name** (string) - Optional - A name for the webhook. - **events** (array of strings) - Required - A list of events to subscribe to (e.g., "activity.sent", "activity.delivered"). - **enabled** (boolean) - Optional - Whether the webhook is enabled (true) or disabled (false). ``` -------------------------------- ### Get List of Scheduled Messages Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of all scheduled messages. ```APIDOC ## Get List of Scheduled Messages ### Description Retrieves a list of all scheduled messages. ### Method ```ruby ms_scheduled_messages.get_list ``` ``` -------------------------------- ### Create an SMS webhook Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Initializes the SMS Webhooks class for creating a new webhook. The actual creation logic would follow. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') # Intialize the SMS Webhooks class ms_sms_webhooks = Mailersend::SMSWebhooks.new(ms_client) ``` -------------------------------- ### Create a DMARC Monitor Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Sets up a new DMARC monitor for a specified domain. Requires the domain ID and your API token. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client) ms_dmarc.create(domain_id: "idofdomain12412") ``` -------------------------------- ### Activity — Get Email Activity Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Retrieve a paginated list of email events (sent, delivered, opened, clicked, bounced, etc.) for a given domain within a date range. ```APIDOC ## Activity — Get Email Activity `Mailersend::Activity#get` — retrieve a paginated list of email events (sent, delivered, opened, clicked, bounced, etc.) for a given domain within a date range. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_activity = Mailersend::Activity.new(ms_client) response = ms_activity.get( domain_id: "zr6ke4n7777893yw", page: 1, limit: 25, date_from: Time.new(2024, 1, 1).to_i, date_to: Time.new(2024, 1, 31).to_i ) data = response.parse data["data"].each do |event| puts "#{event["email"]["subject"]} → #{event["type"]} at #{event["created_at"]}" end ``` ``` -------------------------------- ### Get Email Activity Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Retrieve a paginated list of email events (sent, delivered, opened, clicked, bounced, etc.) for a specific domain and date range. Requires domain ID, page number, limit, and date range. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_activity = Mailersend::Activity.new(ms_client) response = ms_activity.get( domain_id: "zr6ke4n7777893yw", page: 1, limit: 25, date_from: Time.new(2024, 1, 1).to_i, date_to: Time.new(2024, 1, 31).to_i ) data = response.parse data["data"].each do |event| puts "#{event["email"]["subject"]} → #{event["type"]} at #{event["created_at"]}" end ``` -------------------------------- ### Get Single Recipient Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves information for a single recipient using their ID. ```APIDOC ## Get Single Recipient ### Description Retrieves information for a single recipient using their ID. ### Method ```ruby ms_recipients.single(recipient_id: "id124") ``` ### Parameters - **recipient_id** (string) - Required - The ID of the recipient. ``` -------------------------------- ### Create an Email Verification List Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Create a new email verification list with a given name and a list of emails to verify. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_email_verification = Mailersend::EmailVerification.new(ms_client) ms_email_verification.create_a_list(name: "name-your-list", emails: ["example@email.com"]) ``` -------------------------------- ### Send a Single Email Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Initialize the MailSend client and email class, then add recipients, sender, subject, and content (text and HTML) before sending. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') # Intialize the email class ms_email = Mailersend::Email.new(ms_client) # Add parameters ms_email.add_recipients("email" => "ron@parksandrec.com", "name" => "Ron") ms_email.add_recipients("email" => "leslie@parksandrec.com", "name" => "Leslie") ms_email.add_from("email" => "april@parksandrec.com", "name" => "April") ms_email.add_subject("Time") ms_email.add_text("Time is money, money is power, power is pizza, and pizza is knowledge. Let's go.") ms_email.add_html("Time is money, money is power, power is pizza, and pizza is knowledge. Let's go.") # Send the email ms_email.send ``` -------------------------------- ### List Templates Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieve a paginated list of templates for a given domain. Supports specifying page number and limit per page. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_templates = Mailersend::Templates.new(ms_client) ms_templates.list(domain_id: "aax455lll", page: 1, limit: 10) ``` -------------------------------- ### Get SMS Webhook Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific SMS webhook using its ID. ```APIDOC ## Get SMS Webhook ### Description Retrieves details for a specific SMS webhook. ### Method `get_sms_webhook_route` ### Parameters #### Path Parameters - **sms_webhook_id** (String) - Required - The ID of the SMS webhook to retrieve. ``` -------------------------------- ### Create a Token Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Create a new API token with a specified name, scopes, and associated domain ID. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_tokens = Mailersend::Tokens.new(ms_client) ms_tokens.create(name: "Very nice token", scopes: %w[ email_full domains_read ], domain_id: "yourdomainid") ``` -------------------------------- ### Create a monitor Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Creates a new DMARC monitor for a specified domain. Requires the domain ID. ```APIDOC ## Create a monitor ### Description Creates a new DMARC monitor for a specified domain. ### Method ```ruby Mailersend::DmarcMonitoring.create(domain_id: "idofdomain12412") ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **domain_id** (string) - Required - The ID of the domain to create a monitor for. ``` -------------------------------- ### Get SMS Recipient Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific SMS recipient using its ID. ```APIDOC ## Get SMS Recipient ### Description Retrieves details for a specific SMS recipient. ### Method `get` ### Parameters #### Path Parameters - **sms_recipient_id** (String) - Required - The ID of the SMS recipient to retrieve. ``` -------------------------------- ### Get a list of SMS messages Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of SMS messages with pagination options. ```APIDOC ## SMS Messages ### Get a list of SMS messages #### Description Retrieves a list of SMS messages with pagination options. #### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') # Intialize the SMS Messages class ms_sms_messages = Mailersend::SMSMessages.new(ms_client) # Add parameters ms_sms_messages.list(page: 1, limit: 10) ``` #### Parameters ##### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of items per page. ``` -------------------------------- ### Get List of Messages Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a paginated list of messages sent through the Mailersend service. ```APIDOC ## Get List of Messages ### Description Retrieves a paginated list of messages sent through the Mailersend service. ### Method ```ruby ms_messages.list(page: 1, limit: 10) ``` ### Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of items to return per page. ``` -------------------------------- ### List, Fetch, and Delete Email Templates Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Manage reusable email templates. Requires a MailerSend client and Templates instance. Ensure domain_id and template_id are valid. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_templates = Mailersend::Templates.new(ms_client) # List templates for a domain list_resp = ms_templates.list(domain_id: "zr6ke4n7777893yw", page: 1, limit: 10) list_resp.parse["data"].each do |t| puts "#{t["id"]}: #{t["name"]}" end # Fetch a single template (includes variable metadata) single_resp = ms_templates.single(template_id: "zr6ke4n7777893yw") puts single_resp.parse["data"]["name"] # Delete a template ms_templates.delete(template_id: "zr6ke4n7777893yw") ``` -------------------------------- ### Create an email verification list Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Creates a new email verification list with a given name and a list of emails. ```APIDOC ### Create an email verification list #### Description Creates a new email verification list with a given name and a list of emails. #### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_email_verification = Mailersend::EmailVerification.new(ms_client) ms_email_verification.create_a_list(name: "name-your-list", emails: ["example@email.com"]) ``` #### Parameters ##### Request Body - **name** (string) - Required - The name of the email verification list. - **emails** (array of strings) - Required - A list of email addresses to include in the verification list. ``` -------------------------------- ### Get verification status Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Checks the verification status of a domain. Requires the domain ID. ```APIDOC ## Get verification status ### Description Checks the verification status of a domain. ### Method ```ruby Mailersend::Domains.verify(domain_id: "idofdomain12412") ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **domain_id** (string) - Required - The ID of the domain to verify. ``` -------------------------------- ### Send a Basic Email with MailerSend Ruby SDK Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Build and send a single transactional email using the `Mailersend::Email` class. Supports setting sender, recipients (to, cc, bcc), reply-to, subject, text body, HTML body, and tags. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_email = Mailersend::Email.new(ms_client) ms_email.add_from("email" => "sender@yourdomain.com", "name" => "Your App") ms_email.add_recipients("email" => "alice@example.com", "name" => "Alice") ms_email.add_recipients("email" => "bob@example.com", "name" => "Bob") ms_email.add_cc("email" => "cc@example.com", "name" => "CC Person") ms_email.add_bcc("email" => "bcc@example.com", "name" => "BCC Person") ms_email.add_reply_to("email" => "reply@yourdomain.com", "name" => "Support") ms_email.add_subject("Welcome to Our Service!") ms_email.add_text("Hello, thanks for signing up.") ms_email.add_html("
Thanks for signing up.
") ms_email.add_tags("onboarding") response = ms_email.send puts response.status # 202 Accepted on success ``` -------------------------------- ### Get List of Inbound Routes Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieve all configured inbound routes for your Mailersend account. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_inbound_routes = Mailersend::InboundRouting.new(ms_client) ms_inbound_routes.get_inbound_routes ``` -------------------------------- ### Get a single SMS webhook Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific SMS webhook using its ID. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') # Intialize the SMS Webhooks class ms_sms_webhooks = Mailersend::SMSWebhooks.new(ms_client) # Add parameters ms_sms_webhooks.get_sms_webhook_route(sms_webhook_id: 'your-sms-webhook-id') ``` -------------------------------- ### Create, List, Update, and Delete DMARC Monitors Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Manage DMARC monitoring for your sending domains. This includes creating monitors, listing them, updating DMARC policies, and retrieving reports. Requires a MailerSend client and DmarcMonitoring instance. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client) # Create a monitor for a domain create_resp = ms_dmarc.create(domain_id: "zr6ke4n7777893yw") monitor_id = create_resp.parse["data"]["id"] # List all monitors ms_dmarc.list(page: 1, limit: 10) # Update the desired DMARC policy ms_dmarc.update(monitor_id: monitor_id, wanted_dmarc_record: "v=DMARC1; p=reject; pct=100;") # View aggregated report agg_resp = ms_dmarc.report(monitor_id: monitor_id) puts agg_resp.parse # View report for a specific sending IP ms_dmarc.report_by_ip(monitor_id: monitor_id, ip: "198.51.100.42") # View report sources (organizations that sent DMARC reports) ms_dmarc.report_sources(monitor_id: monitor_id) # Mark an IP as favorite / remove from favorites ms_dmarc.add_favorite(monitor_id: monitor_id, ip: "198.51.100.42") ms_dmarc.remove_favorite(monitor_id: monitor_id, ip: "198.51.100.42") # Delete a monitor ms_dmarc.delete(monitor_id: monitor_id) ``` -------------------------------- ### Get a single SMS recipient Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific SMS recipient using its ID. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') # Intialize the SMS Recipient class ms_sms_recipient = Mailersend::SMSRecipient.new(ms_client) # Add parameters ms_sms_recipient.get(sms_recipient_id: 'your-sms-recipient-id') ``` -------------------------------- ### Manage API Tokens Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Create, pause, resume, and delete API tokens with specific scopes and domain associations. Requires a token ID for update and delete operations. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_tokens = Mailersend::Tokens.new(ms_client) # Create a new token with specific scopes create_resp = ms_tokens.create( name: "Production Email Token", domain_id: "zr6ke4n7777893yw", scopes: %w[email_full domains_read analytics_read] ) token_id = create_resp.parse["data"]["id"] puts "Created token: #{token_id}" # Pause a token ms_tokens.update(token_id: token_id, status: "pause") # Resume a token ms_tokens.update(token_id: token_id, status: "unpause") # Delete a token permanently ms_tokens.delete(token_id: token_id) ``` -------------------------------- ### Get Single Scheduled Message Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific scheduled message using its ID. ```APIDOC ## Get Single Scheduled Message ### Description Retrieves details for a specific scheduled message using its ID. ### Method ```ruby ms_scheduled_messages.get_single(message_id: 'mess11454') ``` ### Parameters - **message_id** (string) - Required - The ID of the scheduled message. ``` -------------------------------- ### Get Single Message Info Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves detailed information for a specific message using its ID. ```APIDOC ## Get Single Message Info ### Description Retrieves detailed information for a specific message using its ID. ### Method ```ruby ms_messages.single(message_id: "mess11454") ``` ### Parameters - **message_id** (string) - Required - The ID of the message to retrieve. ``` -------------------------------- ### Get Single Recipient Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Fetches details for a specific recipient using their unique recipient ID. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_recipients = Mailersend::Recipients.new(ms_client) ms_recipients.single(recipient_id: "id124") ``` -------------------------------- ### Opens by reading environment Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves email open data aggregated by reading environment (e.g., desktop, mobile) within a specified date range. ```APIDOC ### Opens by reading environment ### Description Retrieves email open statistics, categorized by the type of environment used to open the email (e.g., webmail, mobile client), for a given date range. ### Method GET ### Endpoint /analytics/opens/user_agent_type ### Parameters #### Query Parameters - **date_from** (integer) - Required - Unix timestamp for the start date. - **date_to** (integer) - Required - Unix timestamp for the end date. ### Request Example ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_analytics = Mailersend::Analytics.new(ms_client) ms_analytics.ua_type(date_from: 1620643567, date_to: 1623321967) ``` ``` -------------------------------- ### Get a list of sender identities Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves a list of all sender identities configured in your Mailersend account. ```APIDOC ## Get a list of sender identities ### Description Retrieves a list of all sender identities configured in your Mailersend account. ### Method ```ruby Mailersend::SenderIdentity.list ``` ### Parameters None ``` -------------------------------- ### Get a single inbound route Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific inbound route using its ID. ```APIDOC ### Get a single inbound route ### Description Retrieves the configuration details for a specific inbound route identified by its unique ID. ### Method GET ### Endpoint /inbound-routing/{inbound_id} ### Parameters #### Path Parameters - **inbound_id** (string) - Required - The ID of the inbound route to retrieve. ### Request Example ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_inbound_routes = Mailersend::InboundRouting.new(ms_client) ms_inbound_routes.get_single_route(inbound_id: 'idofroute12412') ``` ``` -------------------------------- ### Get Bulk Email Status Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieve the status of a bulk email by providing its unique ID. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_bulk_email = Mailersend::BulkEmail.new(ms_client) ms_bulk_email.get_bulk_status(bulk_email_id: 'yourbulkemailid') ``` -------------------------------- ### Retrieve Email Opens by User Agent Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Break down email opens by browser/client name or by environment type (webmail, mobile, desktop). Requires a date range. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_analytics = Mailersend::Analytics.new(ms_client) from = Time.new(2024, 6, 1).to_i to = Time.new(2024, 6, 30).to_i # By client name (e.g., "Gmail", "Apple Mail") ua_name_resp = ms_analytics.ua_name(date_from: from, date_to: to) ua_name_resp.parse["data"]["stats"].each { |s| puts "#{s["name"]}: #{s["count"]}" } # By reading environment type ua_type_resp = ms_analytics.ua_type(date_from: from, date_to: to) ua_type_resp.parse["data"]["stats"].each { |s| puts "#{s["name"]}: #{s["count"]}" } ``` -------------------------------- ### Get SMS Inbound Route Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific SMS inbound route using its ID. ```APIDOC ## Get SMS Inbound Route ### Description Retrieves details for a specific SMS inbound route. ### Method `get_sms_inbound_route` ### Parameters #### Path Parameters - **sms_inbound_id** (String) - Required - The ID of the SMS inbound route to retrieve. ``` -------------------------------- ### Configure Inbound Routing Source: https://context7.com/mailersend/mailersend-ruby/llms.txt Set up routes to forward incoming emails matching filter criteria to webhook URLs. Requires a domain ID and webhook URL. ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_api_token_here') ms_inbound = Mailersend::InboundRouting.new(ms_client) # Create a new inbound route ms_inbound.settings = { 'domain_id' => "zr6ke4n7777893yw", 'name' => "Support Tickets", 'domain_enabled' => true, 'match_filter' => { 'type' => 'match_all' }, 'forwards' => [{ 'type' => 'webhook', 'value' => 'https://app.example.com/inbound' }] } create_resp = ms_inbound.add_inbound_route inbound_id = create_resp.parse["data"]["id"] # List all routes ms_inbound.get_inbound_routes # Get a single route ms_inbound.get_single_route(inbound_id: inbound_id) # Update a route ms_inbound.settings = { 'domain_id' => "zr6ke4n7777893yw", 'name' => "Support Tickets v2", 'domain_enabled' => true, 'match_filter' => { 'type' => 'match_all' }, 'forwards' => [{ 'type' => 'webhook', 'value' => 'https://app.example.com/inbound/v2' }] } ms_inbound.update_inbound_route(inbound_id: inbound_id) # Delete a route ms_inbound.delete_route(inbound_id: inbound_id) ``` -------------------------------- ### Get SMS Phone Number Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves details for a specific SMS phone number using its ID. ```APIDOC ## Get SMS Phone Number ### Description Retrieves details for a specific SMS phone number. ### Method `get` ### Parameters #### Path Parameters - **sms_number_id** (String) - Required - The ID of the SMS phone number to retrieve. ``` -------------------------------- ### Get info on an SMS message Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves detailed information about a specific SMS message using its ID. ```APIDOC ### Get info on an SMS message #### Description Retrieves detailed information about a specific SMS message using its ID. #### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') # Intialize the SMS Messages class ms_sms_messages = Mailersend::SMSMessages.new(ms_client) # Add parameters ms_sms_messages.get_single_route(sms_message_id: 'your-sms-message-id') ``` #### Parameters ##### Query Parameters - **sms_message_id** (string) - Required - The ID of the SMS message to retrieve. ``` -------------------------------- ### Get email verification list results Source: https://github.com/mailersend/mailersend-ruby/blob/main/README.md Retrieves the results of an email verification process for a specific list. ```APIDOC ### Get email verification list results #### Description Retrieves the results of an email verification process for a specific list. #### Method ```ruby require "mailersend-ruby" ms_client = Mailersend::Client.new('your_mailersend_token') ms_email_verification = Mailersend::EmailVerification.new(ms_client) ms_email_verification.get_list_results(email_verification_id: 'your-email-verification-id') ``` #### Parameters ##### Query Parameters - **email_verification_id** (string) - Required - The ID of the email verification list whose results are to be retrieved. ```