https://github.com/imdrasil/email_opener
Preview email in the default browser instead of sending it
https://github.com/imdrasil/email_opener
email email-verification
Last synced: 3 months ago
JSON representation
Preview email in the default browser instead of sending it
- Host: GitHub
- URL: https://github.com/imdrasil/email_opener
- Owner: imdrasil
- License: mit
- Created: 2018-12-17T22:25:29.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-11T20:10:08.000Z (about 3 years ago)
- Last Synced: 2025-03-28T10:50:24.558Z (7 months ago)
- Topics: email, email-verification
- Language: Crystal
- Size: 8.79 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Email Opener [](https://github.com/imdrasil/email_opener/releases) [](https://imdrasil.github.io/email_opener/versions)
Preview email in the default browser instead of sending it. This means you don't 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.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
email_opener:
github: imdrasil/email_opener
```
2. Run `shards install`## Usage
Depending on used email library you need to implement adapter for `EmailOpener`. ATM this library is delivered with [carbon](https://github.com/luckyframework/carbon) adaptor on the board. Here is simple example of basic carbon base mailer:
```crystal
require "email_opener/carbon_adapter"MAILER_ADAPTER = EmailOpener::CarbonAdapter.new
abstract class ApplicationMailer < Carbon::Email
getter email_subject : String, email_address : Stringfrom Carbon::Address.new("Sample App", "noreply@sample-app.com")
to email_address
subject email_subject
settings.adapter = MAILER_ADAPTERdef initialize
@email_address = ""
@email_subject = ""
end
end
```After email is sent HTML part is written to `./tmp/email_opener/rich.html` and opened by default browser.
## Development
To implement own adapter include `EmailOpener::AbstractAdapter` module and invoke in a delivery method `#__deliver__` passing `EmailOpener::Message` with all information regarding email.
```crystal
require "email_opener/abstract_adapter"class OwnAdapter < SomeLibrary::Adapter
include EmailOpener::AbstractAdapterdef deliver(email)
__deliver__(
EmailOpener::Message.new(
email.html_body,
email.text_body,
email.subject,
email.from,
mail.to,
email.cc,
email.bcc,
email.reply_to
)
)
end
end
```## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Roman Kalnytskyi](https://github.com/imdrasil) - creator and maintainer
This library is inspired by ruby library [letter_opener](https://github.com/ryanb/letter_opener).