The project is in a healthy, maintained state
Ruby client DashaMail for transactional API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 3.4.0
 Project Readme

Disclaimer

Оригинальная версия автором больше не поддерживается, и на rubygems может быть залита только с иным названием.

Для дальнейшей поддержки и добавления на rubygems этот форк.

DashaMail

Гем для работы с транзакционным API российского сервиса https://dashamail.ru, с его методами и параметрами можно ознакомиться на официальном ресурсе.

Установка

Добавьте в Gemfile:

gem 'dashamail_transactional'

Затем установите с помощью Bundler

bundle install

Использование

Сконфигурируйте гем в своем проекте:

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

Отправить письмо:

mailer         = DashaMail::Mailer.new
mailer.to      = 'marketing@customer.ru'
mailer.subject = 'Какой-то заголовок'
mailer.message = '<p>Какой-то текст</p><img src="cid:123">'

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

Проверить статус отправки письма:

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/83312d/dashamail_transactional.

License

The gem is available as open source under the terms of the MIT License.

Sponsored by

Логотип проекта