简体   繁体   English

Rails 3 - 生产环境 - smtp电子邮件问题

[英]Rails 3 - Production environment - smtp email issue

I am using smtp settings for sending mails in rails 3. It works fine when sendmail and postfix services are running. 我正在使用smtp设置在rails 3中发送邮件。当sendmailpostfix服务正在运行时,它可以正常工作。 But when I stopped those two services then mails stop sending and giving me connection error. 但当我停止这两个服务,然后邮件停止发送并给我连接错误。

Error log - 错误日志 -

ERROR -- : (Errno::ECONNREFUSED): Connection refused - Connection refused
org/jruby/ext/socket/RubyTCPSocket.java:126:in `initialize'
org/jruby/RubyIO.java:1178:in `open'

If you do not pass any config in your application then it will try to connect localhost on port 25. In your case, this has stopped your SMTP services, that's why you are getting an error. 如果您未在应用程序中传递任何配置,那么它将尝试在端口25上连接localhost。在您的情况下,这已经停止了您的SMTP服务,这就是您收到错误的原因。

So, please add these details below in your config .. in application.rb or depending on your need you can put on development.rb or production.rb 所以,请在你的配置中添加这些详细信息如下。在application.rb ,或者根据您的需要,你可以把development.rbproduction.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    :address        =>  smtp.mailgun.org, # smtp service provider name
    :port           => 587, # port number of smtp server 
    :authentication => 'plain', #plain ////
    :user_name      => '', #user name
    :password       =>'', #password
    :domain         =>  '',#domain name 
    :enable_starttls_auto => true
}

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

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