Pony yandex.ru and mail.ru specifics

独自空忆成欢 提交于 2019-12-23 02:30:28

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/25188703/pony-yandex-ru-and-mail-ru-specifics

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!