{"id":32458073,"url":"https://github.com/mailtrap/mailtrap-ruby","last_synced_at":"2025-10-26T10:03:40.873Z","repository":{"id":37822657,"uuid":"503025016","full_name":"mailtrap/mailtrap-ruby","owner":"mailtrap","description":"The official mailtrap.io Ruby client","archived":false,"fork":false,"pushed_at":"2025-10-21T12:09:57.000Z","size":353,"stargazers_count":25,"open_issues_count":10,"forks_count":7,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-10-23T02:59:27.946Z","etag":null,"topics":["actionmailer","email","mail","mailtrap-io","rails","ruby"],"latest_commit_sha":null,"homepage":"https://mailtrap.io","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mailtrap.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-06-13T16:03:34.000Z","updated_at":"2025-10-21T12:08:57.000Z","dependencies_parsed_at":"2023-09-27T15:45:41.668Z","dependency_job_id":"d46c2406-e5f1-4c24-b565-094876fa8960","html_url":"https://github.com/mailtrap/mailtrap-ruby","commit_stats":{"total_commits":22,"total_committers":5,"mean_commits":4.4,"dds":0.4545454545454546,"last_synced_commit":"11ec223f7293830c1688c5bdbb225ba0955100d7"},"previous_names":["mailtrap/mailtrap-ruby","railsware/mailtrap-ruby"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/mailtrap/mailtrap-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailtrap%2Fmailtrap-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailtrap%2Fmailtrap-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailtrap%2Fmailtrap-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailtrap%2Fmailtrap-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mailtrap","download_url":"https://codeload.github.com/mailtrap/mailtrap-ruby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailtrap%2Fmailtrap-ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280712960,"owners_count":26378085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-23T02:00:06.710Z","response_time":142,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actionmailer","email","mail","mailtrap-io","rails","ruby"],"created_at":"2025-10-26T10:02:12.085Z","updated_at":"2025-10-26T10:03:40.867Z","avatar_url":"https://github.com/mailtrap.png","language":"Ruby","readme":"[![test](https://github.com/mailtrap/mailtrap-ruby/actions/workflows/main.yml/badge.svg)](https://github.com/mailtrap/mailtrap-ruby/actions/workflows/main.yml)\n[![docs](https://shields.io/badge/docs-rubydoc.info-blue)](https://rubydoc.info/gems/mailtrap)\n[![gem](https://shields.io/gem/v/mailtrap)](https://rubygems.org/gems/mailtrap)\n[![downloads](https://shields.io/gem/dt/mailtrap)](https://rubygems.org/gems/mailtrap)\n\n\n\n# Official Mailtrap Ruby client\n\nThis Ruby gem offers integration with the [official API](https://api-docs.mailtrap.io/) for [Mailtrap](https://mailtrap.io).\n\nQuickly add email sending functionality to your Ruby application with Mailtrap.\n\n(This client uses API v2, for v1 refer to [this documentation](https://mailtrap.docs.apiary.io/))\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'mailtrap'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install mailtrap\n\n## Usage\n\n### Ruby on Rails\n\n```ruby\n# place this code in config/environments/production.rb:\nconfig.action_mailer.delivery_method = :mailtrap\n\n# then set the MAILTRAP_API_KEY environment variable\n# using your hosting solution.\n```\n\n### Pure Ruby\n\n```ruby\nrequire 'mailtrap'\n\n# Create mail object\nmail = Mailtrap::Mail.from_content(\n  from: { email: 'mailtrap@example.com', name: 'Mailtrap Test' },\n  to: [\n    { email: 'your@email.com' }\n  ],\n  reply_to: { email: 'support@example.com', name: 'Mailtrap Reply-To' },\n  subject: 'You are awesome!',\n  text: 'Congrats for sending test email with Mailtrap!'\n)\n\n# Create client and send\nclient = Mailtrap::Client.new(api_key: 'your-api-key')\nclient.send(mail)\n\n# You can also pass the request parameters directly\nclient.send(\n  from: { email: 'mailtrap@example.com', name: 'Mailtrap Test' },\n  to: [\n    { email: 'your@email.com' }\n  ],\n  subject: 'You are awesome!',\n  text: 'Congrats for sending test email with Mailtrap!'\n)\n\n```\n\n### Batch Sending\n\nSend up to 500 emails in one API call:\n\n```ruby\nrequire 'mailtrap'\n\nclient = Mailtrap::Client.new(api_key: 'your-api-key')\n\nbatch_base = Mailtrap::Mail.batch_base_from_content(\n  from: { email: 'mailtrap@demomailtrap.co', name: 'Mailtrap Test' },\n  subject: 'You are awesome!',\n  text: 'Congrats for sending test email with Mailtrap!',\n  html: '\u003cp\u003eCongrats for sending test email with Mailtrap!\u003c/p\u003e'\n)\n\nclient.send_batch(\n  batch_base, [\n    Mailtrap::Mail.from_content(\n      to: [\n        { email: 'john.doe@email.com', name: 'John Doe' }\n      ]\n    ),\n    Mailtrap::Mail.from_content(\n      to: [\n        { email: 'jane.doe@email.com', name: 'Jane Doe' }\n      ]\n    )\n  ]\n)\n```\n\n### Email Templates API\n\n```ruby\nrequire 'mailtrap'\n\nclient = Mailtrap::Client.new(api_key: 'your-api-key')\ntemplates = Mailtrap::EmailTemplatesAPI.new 3229, client\n\ntemplates.create(\n  name: 'Welcome Email',\n  subject: 'Welcome to Mailtrap!',\n  body_html: '\u003ch1\u003eHello\u003c/h1\u003e',\n  body_text: 'Hello',\n  category: 'welcome'\n)\n```\n\nRefer to the [`examples`](examples) folder for more examples:\n\n- [Full](examples/full.rb)\n- [Email template](examples/email_template.rb)\n- [Batch Sending](examples/batch.rb)\n- [ActionMailer](examples/action_mailer.rb)\n- [Email Templates API](examples/email_templates_api.rb)\n\n### Content-Transfer-Encoding\n\n`mailtrap` gem uses Mailtrap API to send emails. Mailtrap API does not try to\nreplicate SMTP. That is why you should expect some limitations when it comes to\nsending. For example, `/api/send` endpoint ignores `Content-Transfer-Encoding`\n(see `headers` in the [API documentation](https://railsware.stoplight.io/docs/mailtrap-api-docs/67f1d70aeb62c-send-email)).\nMeaning your recipients will receive emails only in the default encoding which\nis `quoted-printable`, if you send with Mailtrap API.\n\nFor those who need to use `7bit` or any other encoding, SMTP provides\nbetter flexibility in that regard. Go to your _Mailtrap account_ → _Email Sending_\n→ _Sending Domains_ → _Your domain_ → _SMTP/API Settings_ to find the SMTP\nconfiguration example.\n\n### Multiple Mailtrap Clients\n\nYou can configure two Mailtrap clients to operate simultaneously. This setup is\nparticularly useful when you need to send emails using both the transactional\nand bulk APIs. Refer to the configuration example below:\n\n```ruby\n# config/application.rb\nActionMailer::Base.add_delivery_method :mailtrap_bulk, Mailtrap::ActionMailer::DeliveryMethod\n\n# config/environments/production.rb\nconfig.action_mailer.delivery_method = :mailtrap\nconfig.action_mailer.mailtrap_settings = {\n  api_key: 'your-api-key'\n}\nconfig.action_mailer.mailtrap_bulk_settings = {\n  api_key: 'your-api-key',\n  bulk: true\n}\n\n# app/mailers/foo_mailer.rb\nmail(delivery_method: :mailtrap_bulk)\n```\n\n## Migration guide v1 → v2\n\nChange `Mailtrap::Sending::Client` to `Mailtrap::Client`.\n\nIf you use classes which have `Sending` namespace, remove the namespace like in the example above.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on [GitHub](https://github.com/mailtrap/mailtrap-ruby). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Mailtrap project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmailtrap%2Fmailtrap-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmailtrap%2Fmailtrap-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmailtrap%2Fmailtrap-ruby/lists"}