简体   繁体   English

在Ruby 1.8.7中发送邮件

[英]Sending mails in Ruby 1.8.7

I have used 'smtp_tls' gem in ruby 1.8.6 and used smtp_settings for sending mail using 'gmail.com' as domain. 我在ruby 1.8.6中使用了'smtp_tls'gem,并使用smtp_settings使用'gmail.com'作为域发送邮件。 Now i have to use the same functionality in ruby 1.8.7 and i don't know which gem to use and how to use. 现在,我必须在ruby 1.8.7中使用相同的功能,而且我不知道要使用哪个宝石以及如何使用。

I have tried 'action_mailer_tls' gem too. 我也尝试过'action_mailer_tls'gem。

Please tell me the gem for mail notification and method for how to use it. 请告诉我用于邮件通知的gem以及如何使用它的方法。

Thanks 谢谢

in my 1.8.7 ruby project (rails 2.3.5) I have this line in enviroment (because if you want to use gmail, in rails 2.3.x, to send your notification you need to install action_mailer_tls. In rails 3 you don't have to do this because tls is used by default) 在我的1.8.7 ruby​​项目(rails 2.3.5)中,我在环境中有此行(因为如果要在rails 2.3.x中使用gmail,要发送通知,您需要安装action_mailer_tls。在rails 3中,您不需要不必这样做,因为默认情况下使用tls)

config.gem 'action_mailer_tls', :lib => 'smtp_tls.rb'

and in config/initializers/smtp_gmail.rb you can use following setting: 在config / initializers / smtp_gmail.rb中,您可以使用以下设置:

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :authentication       => :plain,
  :enable_starttls_auto => true,
  :user_name            => "your_email_adress@gmail.com",
  :password             => "your_password"

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM