Advertisement
Guest User

Untitled

a guest
Aug 24th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #app/controllers/feedback_info_controller.rb
  2.  
  3. def send_mail
  4. smtp = Net::SMTP.new( "smtp.yandex.ru", 587 )
  5. smtp.enable_starttls
  6. smtp.start( "yandex.ru", "my_adr@yandex.ru", "пароль", :plain ) do |conn|
  7. conn.send_message "Сообщение", "my_adr@yandex.ru", "получатель@rambler.ru"
  8. end
  9.  
  10. by mx2.mail.rambler.ru (Postfix) with ESMTP id 65FF15CA8
  11. for <получатель@rambler.ru>; Mon, 24 Aug 2015 11:13:46 +0300 (MSK)
  12.  
  13. by forward22m.cmail.yandex.net (Yandex) with ESMTP id 488F18046B
  14. for <получатель911@rambler.ru>; Mon, 24 Aug 2015 11:13:46 +0300 (MSK)
  15.  
  16. by smtp3m.mail.yandex.net (Yandex) with ESMTP id 2C1A127A05B8
  17. for <получатель911@rambler.ru>; Mon, 24 Aug 2015 11:13:46 +0300 (MSK)
  18.  
  19. #app/mailers/application_mailer.rb
  20. class ApplicationMailer < ActionMailer::Base
  21. end
  22.  
  23. #app/mailers/feedback_mailer.rb
  24. class FeedbackMailer < ApplicationMailer
  25. def feedback_email
  26. mail(from: 'my_adr@yandex.ru', to: 'получатель@rambler.ru', subject: 'тема')
  27. end
  28. end
  29.  
  30. #app/controllers/feedback_info_controller.rb
  31. def feedback_send
  32. FeedbackMailer.feedback_email
  33. end
  34.  
  35. #config/environments/development.rb
  36. config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  37. config.action_mailer.delivery_method = :smtp
  38. config.action_mailer.smtp_settings = {
  39. address: 'smtp.yandex.ru',
  40. port: 587,
  41. domain: 'yandex.ru',
  42. authentication: 'plain',
  43. user_name: 'my_adr@yandex.ru',
  44. password: 'пароль',
  45. enable_starttls_auto: true
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement