Fixed #38 - added folder option.
This commit is contained in:
parent
6f03f17a7a
commit
d438f3947c
3 changed files with 26 additions and 6 deletions
|
@ -371,14 +371,20 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
|
|||
|
||||
render: (data = {}) ->
|
||||
|
||||
if !data['options']
|
||||
data['options'] = {}
|
||||
data['options']['ssl'] = true
|
||||
data['active'] = true
|
||||
|
||||
configure_attributes = [
|
||||
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { IMAP: 'IMAP', POP3: 'POP3' } , class: 'span4', default: data['adapter'] },
|
||||
{ name: 'host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, class: 'span4', autocapitalize: false, default: (data['options']&&data['options']['host']) },
|
||||
{ name: 'user', display: 'User', tag: 'input', type: 'text', limit: 120, null: false, class: 'span4', autocapitalize: false, default: (data['options']&&data['options']['user']) },
|
||||
{ name: 'password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: false, class: 'span4', autocapitalize: false, default: (data['options']&&data['options']['password']) },
|
||||
{ name: 'ssl', display: 'SSL', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' } , class: 'span4', default: (data['options']&&data['options']['ssl']) },
|
||||
{ name: 'ssl', display: 'SSL', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' }, translate: true, class: 'span4', default: (data['options']&&data['options']['ssl']) },
|
||||
{ name: 'folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, class: 'span4', autocapitalize: false, default: (data['options']&&data['options']['folder']) },
|
||||
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, filter: @edit_form, nulloption: false, relation: 'Group', class: 'span4', default: data['group_id'] },
|
||||
{ name: 'active', display: 'Active', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' } , class: 'span4', default: data['active'] },
|
||||
{ name: 'active', display: 'Active', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' } , translate: true, class: 'span4', default: data['active'] },
|
||||
]
|
||||
if @object
|
||||
@html App.view('generic/admin/edit')(
|
||||
|
@ -416,6 +422,7 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
|
|||
user: params['user'],
|
||||
password: params['password'],
|
||||
ssl: params['ssl'],
|
||||
folder: params['folder'],
|
||||
},
|
||||
active: params['active'],
|
||||
)
|
||||
|
|
|
@ -24,7 +24,11 @@ class Channel::IMAP < Channel::EmailParser
|
|||
end
|
||||
imap.login( channel[:options][:user], channel[:options][:password] )
|
||||
end
|
||||
imap.select('INBOX')
|
||||
if channel[:options][:folder].empty?
|
||||
imap.select('INBOX')
|
||||
else
|
||||
imap.select( channel[:options][:folder] )
|
||||
end
|
||||
count = 0
|
||||
count_all = imap.search(['ALL']).count
|
||||
imap.search(['ALL']).each do |message_id|
|
||||
|
|
|
@ -4,10 +4,19 @@ class Channel::POP3 < Channel::EmailParser
|
|||
include UserInfo
|
||||
|
||||
def fetch (channel)
|
||||
puts "fetching pop3 (#{channel[:options][:host]}/#{channel[:options][:user]})"
|
||||
ssl = false
|
||||
port = 110
|
||||
if channel[:options][:ssl].to_s == 'true'
|
||||
ssl = true
|
||||
port = 995
|
||||
end
|
||||
|
||||
pop = Net::POP3.new( channel[:options][:host], 995 )
|
||||
pop.enable_ssl
|
||||
puts "fetching pop3 (#{channel[:options][:host]}/#{channel[:options][:user]} port=#{port},ssl=#{ssl})"
|
||||
|
||||
pop = Net::POP3.new( channel[:options][:host], port )
|
||||
if ssl
|
||||
pop.enable_ssl
|
||||
end
|
||||
pop.start( channel[:options][:user], channel[:options][:password] )
|
||||
count = 0
|
||||
count_all = pop.mails.size
|
||||
|
|
Loading…
Reference in a new issue