음, 나는 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
그런 다음 당신이보기에 해당 메시지를 넣을 수 있습니다 - 또는 하나의 대량 이메일에 모두 보내거나 네가하고 싶은게 뭐든간에.
(500pts) 내게 맞춤 보석을 만들어야합니다. jk! 이 문제에 대해 감사 드리며 조사해 보겠습니다. – s84
하하,이 아이디어에 관심이 있습니다. 위에 추가 한 요지가 유용하다는 것을 알려주십시오. – Kelly
@Sam 모든 재 작성을 죄송합니다. 위의 코드가 더 유용 할 것 같습니다. – Kelly