{"id":13427865,"url":"https://github.com/ryanb/letter_opener","last_synced_at":"2025-05-12T09:23:31.574Z","repository":{"id":671278,"uuid":"2344621","full_name":"ryanb/letter_opener","owner":"ryanb","description":"Preview mail in the browser instead of sending.","archived":false,"fork":false,"pushed_at":"2024-08-02T07:09:54.000Z","size":237,"stargazers_count":3768,"open_issues_count":3,"forks_count":239,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-05-07T11:12:29.686Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/ryanb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2011-09-07T21:17:22.000Z","updated_at":"2025-05-04T23:56:23.000Z","dependencies_parsed_at":"2024-06-18T10:51:06.346Z","dependency_job_id":"60e06c7e-ac94-47a6-84d2-1c1e90a85cc4","html_url":"https://github.com/ryanb/letter_opener","commit_stats":{"total_commits":252,"total_committers":67,"mean_commits":"3.7611940298507465","dds":0.5912698412698413,"last_synced_commit":"9038f2526619e9807191d50bf69d0c8599d75725"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanb%2Fletter_opener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanb%2Fletter_opener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanb%2Fletter_opener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanb%2Fletter_opener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanb","download_url":"https://codeload.github.com/ryanb/letter_opener/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253060280,"owners_count":21847492,"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","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":[],"created_at":"2024-07-31T01:00:41.568Z","updated_at":"2025-05-11T08:37:08.229Z","avatar_url":"https://github.com/ryanb.png","language":"Ruby","readme":"# Letter Opener [![Ruby](https://github.com/ryanb/letter_opener/actions/workflows/ruby.yml/badge.svg)](https://github.com/ryanb/letter_opener/actions/workflows/ruby.yml)\n\nPreview email in the default browser instead of sending it. This means you do not need to set up email delivery in your development environment, and you no longer need to worry about accidentally sending a test email to someone else's address.\n\n## Rails Setup\n\nFirst add the gem to your development environment and run the `bundle` command to install it.\n\n```rb\ngem \"letter_opener\", group: :development\n```\n\nThen set the delivery method in `config/environments/development.rb`\n\n```rb\nconfig.action_mailer.delivery_method = :letter_opener\nconfig.action_mailer.perform_deliveries = true\n```\n\nNow any email will pop up in your browser instead of being sent. The messages are stored in `tmp/letter_opener`.\nIf you want to change application that will be used to open your emails you should override `LAUNCHY_APPLICATION` environment variable or set `Launchy.application` in the initializer.\n\n### Configuration\n\n```rb\nLetterOpener.configure do |config|\n  # To overrider the location for message storage.\n  # Default value is `tmp/letter_opener`\n  config.location = Rails.root.join('tmp', 'my_mails')\n\n  # To render only the message body, without any metadata or extra containers or styling.\n  # Default value is `:default` that renders styled message with showing useful metadata.\n  config.message_template = :light\n\n  # To change default file URI scheme you can provide `file_uri_scheme` config.\n  # It might be useful when you use WSL (Windows Subsystem for Linux) and default\n  # scheme doesn't work for you.\n  # Default value is blank\n  config.file_uri_scheme = 'file://///wsl$/Ubuntu-18.04'\nend\n```\n\n## Non Rails Setup\n\nIf you aren't using Rails, this can be easily set up with the Mail gem. Just set the delivery method when configuring Mail and specify a location.\n\n```rb\nrequire \"letter_opener\"\nMail.defaults do\n  delivery_method LetterOpener::DeliveryMethod, location: File.expand_path('../tmp/letter_opener', __FILE__)\nend\n```\n\nThe method is similar if you're using the Pony gem:\n\n```rb\nrequire \"letter_opener\"\nPony.options = {\n  via: LetterOpener::DeliveryMethod,\n  via_options: {location: File.expand_path('../tmp/letter_opener', __FILE__)}\n}\n```\n\nAlternatively, if you are using ActionMailer directly (without Rails) you will need to add the delivery method.\n\n```rb\nrequire \"letter_opener\"\nActionMailer::Base.add_delivery_method :letter_opener, LetterOpener::DeliveryMethod, :location =\u003e File.expand_path('../tmp/letter_opener', __FILE__)\nActionMailer::Base.delivery_method = :letter_opener\n```\n\n## Remote Alternatives\n\nLetter Opener uses [Launchy](https://github.com/copiousfreetime/launchy) to open sent mail in the browser. This assumes the Ruby process is running on the local development machine. If you are using a separate staging server or VM this will not work. In that case consider using [Mailtrap](http://mailtrap.io/) or [MailCatcher](http://mailcatcher.me/).\n\nIf you are running your application within a Docker Container or VM and do not have a browser available to open emails received by Letter Opener, you may see the following error:\n\n```\nWARN: Launchy::CommandNotFoundError: Unable to find a browser command. If this is unexpected, Please rerun with environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at https://github.com/copiousfreetime/launchy/issues/new\n```\n\nTo resolve this, simply set the following ENV variables:\n\n```\nLAUNCHY_DRY_RUN=true\nBROWSER=/dev/null\n```\n\nIn order to keep this project simple, I don't have plans to turn it into a Rails engine with an interface for browsing the sent mail but there is a [gem you can use for that](https://github.com/fgrehm/letter_opener_web).\n\n\n## Development \u0026 Feedback\n\nQuestions or problems? Please use the [issue tracker](https://github.com/ryanb/letter_opener/issues). If you would like to contribute to this project, fork this repository and run `bundle` and `rake` to run the tests. Pull requests appreciated.\n\nSpecial thanks to the [mail_view](https://github.com/37signals/mail_view/) gem for inspiring this project and for their mail template. Also thanks to [Vasiliy Ermolovich](https://github.com/nashby) for helping manage this project.\n","funding_links":[],"categories":["Communication","Email","Ruby","Vanilla Libraries and Hanami","Debug","调试","WebSocket","Development"],"sub_categories":["E-Mail Preview","Editors and IDE","Omniauth"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanb%2Fletter_opener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanb%2Fletter_opener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanb%2Fletter_opener/lists"}