rubysinatrapony

Pony yandex.ru and mail.ru specifics


I am creating a form in Sinatra that will be sending data to an e-mail on submit using Pony gem. This is my code so far:

post '/pemco' do 

Pony.mail(
  :from => params[:name] + "<" + params[:email] + ">",
  :to => '___@yandex.ru',
  :subject => params[:name] + " has contacted you",
  :body => params[:message],

  :via => :smtp,
  :via_options => { 
    :address              => 'smtp.yandex.ru', 
    :port                 => '465', 
    :enable_starttls_auto => true, 
    :user_name            => '___', 
    :password             => '___', 
    :authentication       => :plain
  })
redirect '/' 
end

I press submit, response pends for some time and then I get Net::ReadTimeout file: protocol.rb location: rescue in rbuf_fill line: 158 error. What am I doing wrong?


Solution

  • This code works for yandex.ru (and you need to go here https://mail.yandex.ru/neo2/#setup/client and allow everything):

    post '/sent' do
      Pony.mail(
        :to => "_yourEmail_@yandex.ru",
        :from => "_sameYourEmail_@yandex.ru",
    
        :via => :smtp,
        :via_options => { 
          :address              => 'smtp.yandex.ru', 
          :port                 => '25', 
          :enable_starttls_auto => true, 
          :user_name            => '_yourUsername_', 
          :password             => '_yourPassword_', 
          :authentication       => :plain
        })
    end
    

    And same code works for mail.ru (and generally you don't need to do anything else).