Skip to content

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

License

Notifications You must be signed in to change notification settings

creadone/dashamail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DashaMail

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

Установка

Укажите в проекте загрузку гема из гитхаба:

gem 'dashamail', git: 'https://github.com/creadone/dashamail'

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

bundle install

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

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

DashaMail.configure do |config|
  config.api_key    = 'ваш API-ключ'
  config.domain     = 'my-domain.ru'
  config.from_email = '[email protected]'
  config.from_name  = 'Отдел маркетинга'
  # config.http_debug = true
end

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

mailer         = DashaMail::Mailer.new
mailer.to      = '[email protected]'
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"=>"[email protected]",
#    "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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published