Rails没有发在AWS上的电子邮件 [英] Rails does not send emails on AWS
问题描述
我试着从我的Rails应用程序发送确认电子邮件。在我的开发环境中的正常使用(在Ubuntu)。但是,当我尝试发送的电子邮件在我的亚马逊AWS EC2实例,它不工作。我得到一个错误日志:
Im trying to send confirmation emails from my Rails application. In my development environment its working perfectly (in ubuntu). However, when I try to send the emails in my Amazon AWS EC2 instance, it is not working. I get next error log:
BookingRequestEvent.execute
{ 38227580 rufus-scheduler intercepted an error:
38227580 job:
38227580 Rufus::Scheduler::EveryJob "60s" {}
38227580 error:
38227580 38227580
38227580 Errno::ECONNREFUSED
38227580 Connection refused - connect(2)
38227580 /home/ubuntu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/smtp.rb:541:in `initialize'
38227580 /home/ubuntu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/smtp.rb:541:in `open'
38227580 /home/ubuntu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/smtp.rb:541:in `tcp_socket'
38227580 /home/ubuntu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/smtp.rb:551:in `block in do_start'
38227580 /home/ubuntu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
38227580 /home/ubuntu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/smtp.rb:550:in `do_start'
38227580 /home/ubuntu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/smtp.rb:520:in `start'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/mail-2.5.4/lib/mail/message.rb:2129:in `do_delivery'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/mail-2.5.4/lib/mail/message.rb:232:in `block in deliver'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:456:in `block in deliver_mail'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.0/lib/active_support/notifications.rb:159:in `block in instrument'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.0/lib/active_support/notifications.rb:159:in `instrument'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:454:in `deliver_mail'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/mail-2.5.4/lib/mail/message.rb:232:in `deliver'
38227580 /home/ubuntu/apps/yanpyapi/app/models/notification_manager.rb:6:in `notify'
38227580 /home/ubuntu/apps/yanpyapi/app/models/events/booking_request_event.rb:22:in `execute'
38227580 /home/ubuntu/apps/yanpyapi/app/models/secretary.rb:85:in `block in executeEvents'
38227580 /home/ubuntu/apps/yanpyapi/app/models/secretary.rb:20:in `each'
38227580 /home/ubuntu/apps/yanpyapi/app/models/secretary.rb:20:in `executeEvents'
38227580 /home/ubuntu/apps/yanpyapi/config/initializers/task_scheduler.rb:8:in `block in <top (required)>'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/rufus-scheduler-3.0.3/lib/rufus/scheduler/jobs.rb:224:in `call'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/rufus-scheduler-3.0.3/lib/rufus/scheduler/jobs.rb:224:in `do_trigger'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/rufus-scheduler-3.0.3/lib/rufus/scheduler/jobs.rb:269:in `block (3 levels) in start_work_thread'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/rufus-scheduler-3.0.3/lib/rufus/scheduler/jobs.rb:272:in `call'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/rufus-scheduler-3.0.3/lib/rufus/scheduler/jobs.rb:272:in `block (2 levels) in start_work_thread'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/rufus-scheduler-3.0.3/lib/rufus/scheduler/jobs.rb:258:in `loop'
38227580 /home/ubuntu/.rvm/gems/ruby-2.0.0-p451/gems/rufus-scheduler-3.0.3/lib/rufus/scheduler/jobs.rb:258:in `block in start_work_thread'
} 38227580 .
我看到一个连接被拒绝的消息,我想我应该配置一些安全凭证或打开一些端口...但我不知道。
I see a connection refused message, I guess I should config some security credential or open some port... but I have no idea.
更新
要提供一些更多的细节。我的电子邮件服务是由百会提供的,我配置了一些帐户。我配置了两个MX记录集AWS与路线53.邮件的工作,我的意思是,我可以发送和从其他帐户,如Gmail或Hotmail我ZOHO帐户接收电子邮件。正如我所说,电子邮件服务正在与这些帐户的发展(这是另一个Ubuntu的)。
To provide some more details. My email service is provided by Zoho, I configured some accounts. I configured two MX record sets in AWS with Route 53. The mail is working, I mean, I can send and receive email from another accounts such as gmail or hotmail to my zoho accounts. And as I said, the email service is working with these accounts in development (which is another ubuntu).
推荐答案
您运行从内一个VPC此应用程序?如果是这样,请确认您的NAT实例的安全组允许SMTP入站/出站通信。如果它是一个经典的EC2实例,在实例的SG做同样的。
Are you running this application from inside a VPC? If so, verify that your NAT instance's security group allows SMTP inbound/outbound traffic. If it's a classic EC2 instance, do the same in your instance's SG.
这篇关于Rails没有发在AWS上的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!