我有以下简单的脚本,它检查电子邮件帐户,如果有新邮件,它会转发电子邮件并发送短信。当脚本在没有Process.daemon
. 添加后,电子邮件帐户收到电子邮件,没有任何反应(没有转发,也没有发送 SMS)并且控制台中没有错误消息。有什么建议么?
#!/usr/bin/env ruby
require "bundler/setup"
require "mailman"
require "twilio-ruby"
Mailman.config.pop3 = {
:username => 'address@gmail.com',
:password => 'password',
:server => 'pop.gmail.com',
:port => 995,
:ssl => true
}
Mailman.config.poll_interval = 60
Mailman::Application.run do
default do
begin
Ticket.receive_mail(message)
MailForwarder.forwarded_email(message).deliver
@account_sid = 'xxxxxxxxxxx'
@auth_token = 'xxxxxxxxxx'
@client = Twilio::REST::Client.new(@account_sid, @auth_token)
@account = @client.account
@sms = @account.sms.messages.create(
:from => '+1111111111',
:to => '+122222222',
:body => message.subject
)
puts @sms
puts "#{message.subject}"
rescue Exception => e
Mailman.logger.error "Exception occurred whle receiving message:\n#{message}"
Mailman.logger.error [e, *e.backtrace].join("\n")
end
end
Process.daemon
end