Created
May 11, 2014 11:39
-
-
Save Kein1945/5348b99dcec1ec44f3fb to your computer and use it in GitHub Desktop.
Send emails in RoR via pdd.yandex.ru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeController < ApplicationController | |
def contacts | |
UserMailer.notify_email( params[:text]).deliver | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Restorator::Application.configure do | |
# ... | |
config.action_mailer.raise_delivery_errors = true | |
config.action_mailer.perform_deliveries = true | |
config.action_mailer.smtp_settings = { | |
address: 'smtp.yandex.ru', | |
domain: 'smtp.yandex.ru', | |
port: 25, | |
user_name: 'noreply@domain.com', | |
password: 'secure_password', | |
authentication: :login, | |
# enable_starttls_auto: true | |
} | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
class UserMailer < ActionMailer::Base | |
default from: 'noreply@domain.com' | |
def notify_email(text) | |
#cF1yuTD86jsqZay90ATq | |
delivery_options = { user_name: 'noreply@domain.com', | |
password: 'secure_password', | |
address: 'smtp.yandex.ru' } | |
mail(to: 'receiver@domain.com', | |
body: "Text", | |
content_type: "text/plain", | |
subject: 'Subject from domain.com', | |
delivery_method_options: delivery_options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment