https://github.com/creadone/dashamail
Гем для работы с транзакционным API российского сервиса https://dashamail.ru
https://github.com/creadone/dashamail
Last synced: 11 months ago
JSON representation
Гем для работы с транзакционным API российского сервиса https://dashamail.ru
- Host: GitHub
- URL: https://github.com/creadone/dashamail
- Owner: creadone
- License: mit
- Created: 2023-02-19T17:27:40.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-22T17:35:23.000Z (over 3 years ago)
- Last Synced: 2025-04-13T13:13:51.561Z (about 1 year ago)
- Language: Ruby
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DashaMail
Гем для работы с транзакционным API российского сервиса https://dashamail.ru, с его методами и параметрами можно ознакомиться на [официальном ресурсе](https://dashamail.ru/transactional/).
## Установка
Укажите в проекте загрузку гема из гитхаба:
```sh
gem 'dashamail', git: 'https://github.com/creadone/dashamail'
```
Затем установите с помощью Bundler
```sh
bundle install
```
## Использование
Сконфигурируйте гем в своем проекте:
```ruby
DashaMail.configure do |config|
config.api_key = 'ваш API-ключ'
config.domain = 'my-domain.ru'
config.from_email = 'marketing@my-domain.ru'
config.from_name = 'Отдел маркетинга'
# config.http_debug = true
end
```
Отправить письмо:
```ruby
mailer = DashaMail::Mailer.new
mailer.to = 'marketing@customer.ru'
mailer.subject = 'Какой-то заголовок'
mailer.message = '
Какой-то текст
'
mailer.add_attachment './attachment.png'
mailer.add_inline './inline_attachment.png', 123
response = mailer.send
if response.success?
pp response.body
# {"msg"=>
# {"err_code"=>0,
# "text"=>"OK",
# "type"=>"message"},
# "data"=>
# {"transaction_id"=>"5a802b10ba82eccfd164f3c8be0fb678"}}
pp response.transaction_id #=> 5a802b10ba82eccfd164f3c8be0fb678
end
```
Проверить статус отправки письма:
```ruby
mailer = DashaMail::Mailer.new
response = mailer.check('5a802b10ba82eccfd164f3c8be0fb678')
pp response.data
# {"data"=>
# {"date"=>"2023-02-22 19:14:42",
# "datesent"=>"2023-02-22 19:14:42",
# "to"=>"marketing@customer.ru",
# "status"=>5,
# "statusname"=>"Sent",
# "statuschangedate"=>"2023-02-22 19:14:42"},
# "success"=>true}
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/creadone/dashamail.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).