2011-03-23 3 views
3

google apps를 사용하는 관리자 사용자에게 Gmail 직원의 이메일 모니터링 기능을 제공해야합니다. 이를 위해 Google의 감사 API를 사용 해본 적이 있습니까?Google의 감사 API를 사용하여 Google 앱 이메일 모니터링

관리자 분들께서 내 사용자 이메일을 클릭하는 방법이 있었으면 좋겠지 만, 그렇지는 않습니다.

응용 프로그램이 중요한 경우 레일 응용 프로그램입니다. 이메일은 google apps를 통해 googles 메일로 완전히 완료됩니다. 이 조언을 해 준 사람이면 누구나 도움이 될 것입니다.

업데이트! 이 500 포인트!

저는 heroku에서 앱을 호스팅하는 레일에 루비를 사용하고 있습니다. 전자 메일은 비즈니스가 아닌 Google Apps 표준으로 완전히 호스팅되므로 업그레이드해야하며 DNS는 영웅을 사용하는 경우 이미 알고있는 zerigo입니다.

답변

8

음, 나는 gdata-ruby-util 보석을 확장 할 계획이 없었습니다. :)하지만 Google의 documentation에 기반한 Google 감사 API에 사용할 수있는 코드는 다음과 같습니다. 나는 단지 create_monitor_on 방법을 썼지 만, 나머지는 꽤 쉽게 얻을 수 있습니다.

작동 또는 재 작성을 필요로하는 경우 알려 주시면 여기를 업데이트 할 수 있습니다 :

class Audit < GData::Client::Base 

     attr_accessor :store_at 

     def initialize(options = {}) 
     options[:clientlogin_service] ||= 'apps' 
     options[:authsub_scope] ||= 'https://apps-apis.google.com/a/feeds/compliance/audit/' 
     super(options) 
     end 

     def create_monitor_on(email_address) 
     user_name, domain_name = email_address.split('@') 
     entry = <<-EOF 
     <atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'> 
     <apps:property name='destUserName' value='#{@store_at}'/> 
     <apps:property name='beginDate' value=''/> 
     <apps:property name='endDate' value='2019-06-30 23:20'/> 
     <apps:property name='incomingEmailMonitorLevel' value='FULL_MESSAGE'/> 
     <apps:property name='outgoingEmailMonitorLevel' value='FULL_MESSAGE'/> 
     <apps:property name='draftMonitorLevel' value='FULL_MESSAGE'/> 
     <apps:property name='chatMonitorLevel' value='FULL_MESSAGE'/> 
     </atom:entry> 
     EOF 

     return true if post('https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/'+domain_name+'/'+user_name, entry).status_code == 201 
     false 
     end 
    end 

을 다음과 같이 다른 곳에서 사용

auditor = Audit.new 
auditor.store_at = 'this-username' 
auditor.clientlogin(username, password) 
render :success if auditor.create_monitor_on('[email protected]') 

나의 제안은 하나 개의 코어를 만드는 것입니다 모든 전자 메일 모니터가 전송되는 전자 메일 주소이므로 관리자의받은 편지함이 다른 사람의 메일과 함께 스팸되지 않습니다. 그런 다음 Rails 응용 프로그램에서 Net :: IMAP을 사용하여 해당 전자 메일 계정에서 원하는 메시지를 다운로드하십시오. 즉, 당신은 "보기 조의 리스팅"라는 링크를 만들 수 있습니다 및 방법은 다음과 같이 수행합니다

require 'net/imap' 

imap = Net::IMAP.new('imap.gmail.com', 993, true) 
imap.login('[email protected]', password) 
imap.select('INBOX') 

messages = [] 
imap.search(["TO", "[email protected]").each do |msg_id| 
    msg = imap.fetch(msg_id, "(UID RFC822.SIZE ENVELOPE BODY[TEXT])")[0] 
    body = msg.attr["BODY[TEXT]"] 
    env = imap.fetch(msg_id, "ENVELOPE")[0].attr["ENVELOPE"] 
    messages << {:subject => env.subject, :from => env.from[0].name, :body => body } 
end 

imap.logout 
imap.disconnect 

그런 다음 당신이보기에 해당 메시지를 넣을 수 있습니다 - 또는 하나의 대량 이메일에 모두 보내거나 네가하고 싶은게 뭐든간에.

+0

(500pts) 내게 맞춤 보석을 만들어야합니다. jk! 이 문제에 대해 감사 드리며 조사해 보겠습니다. – s84

+0

하하,이 아이디어에 관심이 있습니다. 위에 추가 한 요지가 유용하다는 것을 알려주십시오. – Kelly

+0

@Sam 모든 재 작성을 죄송합니다. 위의 코드가 더 유용 할 것 같습니다. – Kelly

관련 문제