daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Oct 17th, 2017 144 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 <получатель@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 <получатель@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.     }
  47.    
  48. config.action_mailer.smtp_settings = {
  49. tls: true,
  50.    
  51. #development.rb
  52. config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  53. config.action_mailer.delivery_method = :smtp
  54. config.action_mailer.smtp_settings = {
  55. :tls => true,
  56. address: 'smtp.yandex.ru',
  57. port: 465,
  58. domain: 'yandex.ru',
  59. authentication: 'plain',
  60. user_name: 'name@yandex.ru',
  61. password: 'пароль'
  62. }
  63.  
  64.  
  65. #mailers/application_mailer.rb
  66. class ApplicationMailer < ActionMailer::Base
  67. end
  68.  
  69.  
  70. #mailers/feedback_mailer.rb
  71. class FeedbackMailer < ApplicationMailer
  72.  
  73. def feedback_email (name, phone, comment)
  74. @name = name
  75. @phone = phone
  76. @comment = comment
  77. mail(from: 'name@yandex.ru', to: 'adrr@example.com', subject: 'Тема письма')
  78. end
  79. end
  80.  
  81.  
  82. #controllers/feedback_info_controller.rb
  83. def feedback_send
  84.  
  85. @name = CGI.escapeHTML(params[:feedback_info][:name])
  86. @phone = CGI.escapeHTML(params[:feedback_info][:phone])
  87. @comment = CGI.escapeHTML(params[:feedback_info][:comment])
  88.  
  89. FeedbackMailer.feedback_email(@name,@phone,@comment).deliver_now  
  90. end
  91.    
  92. FeedbackMailer.feedback_email.deliver_later
  93.    
  94. config.action_mailer.default_url_options = { host: 'www.yoursite.ru' }
  95. config.action_mailer.perform_deliveries = true
  96. config.action_mailer.delivery_method = :smtp
  97. config.action_mailer.smtp_settings = {
  98.   tls: true,
  99.   address: "smtp.yandex.com",
  100.   port: 465,
  101.   domain: "yandex.com",
  102.   authentication: "plain",
  103.   enable_starttls_auto: true,
  104.   user_name: 'youremail@yandex.ru',
  105.   password: 'yourpassword'
  106. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top