https://github.com/andyw8/actionmailing
https://github.com/andyw8/actionmailing
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/andyw8/actionmailing
- Owner: andyw8
- License: mit
- Created: 2019-01-08T00:34:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-12T00:14:44.000Z (over 6 years ago)
- Last Synced: 2025-01-05T19:12:45.957Z (5 months ago)
- Language: Ruby
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ActionMailing
ActionMailing allows you to represent emails as plain Ruby classes which complement ActionMailer.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'actionmailing'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install actionmailing
## Usage
Define a mailing:
```ruby
class WelcomeMailing
include ActionMailing::Mailingdef
"[email protected]"
end
def from
"[email protected]"
end
def subject
"Welcome #{user.name}"
enddef initialize(user)
@user = user
endprivate
attr_reader :user
end
```Calling the mailing from the mailer:
```ruby
class UserMailer < ActionMailer::Base
include ActionMailing::Mailer# No need to call `mail`, just return a Mailing
def welcome(user)
WelcomeMailing.new(user)
end
end
```Send the mail in the usual way:
```ruby
WelcomeMailer.welcome(user).deliver_later
```## Development
After 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.
To 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Unit Testing
Mailings are plain Ruby classes, so are easy to test with your preferred framework.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/actionmailing.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).