Skip to content

Instantly share code, notes, and snippets.

@Kein1945
Created May 11, 2014 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kein1945/5348b99dcec1ec44f3fb to your computer and use it in GitHub Desktop.
Save Kein1945/5348b99dcec1ec44f3fb to your computer and use it in GitHub Desktop.
Send emails in RoR via pdd.yandex.ru
class HomeController < ApplicationController
def contacts
UserMailer.notify_email( params[:text]).deliver
end
end
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
#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