mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 00:20:05 +08:00
feat(mail): add login & password option
This commit is contained in:
parent
31ab74f8be
commit
5ec1b3beb5
@ -16,6 +16,7 @@
|
||||
" 1. `imap_host`: set the imap server host
|
||||
" 2. `imap_port`: set the imap server port
|
||||
" 3. `imap_login`: set the login of imap server
|
||||
" 4. `imap_password`: set the password of imap server
|
||||
"
|
||||
" @subsection key bindings
|
||||
" >
|
||||
@ -30,6 +31,7 @@ endif
|
||||
let s:imap_host = 'imap.163.com'
|
||||
let s:imap_port = 143
|
||||
let s:imap_login = ''
|
||||
let s:imap_password = ''
|
||||
|
||||
function! SpaceVim#layers#mail#plugins() abort
|
||||
return [
|
||||
@ -40,6 +42,8 @@ endfunction
|
||||
function! SpaceVim#layers#mail#set_variable(opt) abort
|
||||
let s:imap_host = get(a:opt, 'imap_host', s:imap_host)
|
||||
let s:imap_port = get(a:opt, 'imap_port', s:imap_port)
|
||||
let s:imap_login = get(a:opt, 'imap_login', s:imap_login)
|
||||
let s:imap_password = get(a:opt, 'imap_password', s:imap_password)
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#mail#config() abort
|
||||
@ -47,6 +51,7 @@ function! SpaceVim#layers#mail#config() abort
|
||||
let g:mail_imap_host = s:imap_port
|
||||
let g:mail_imap_port = s:imap_port
|
||||
let g:mail_imap_login = s:imap_login
|
||||
let g:mail_imap_password = s:imap_password
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#mail#health() abort
|
||||
|
@ -89,11 +89,9 @@ endfunction
|
||||
|
||||
function! mail#client#open()
|
||||
if s:job_id == 0
|
||||
let username = input('USERNAME: ')
|
||||
let password = input('PASSWORD: ')
|
||||
if !empty(username) && !empty(password)
|
||||
if !empty(g:mail_imap_login) && !empty(g:mail_imap_password)
|
||||
call mail#client#connect(g:mail_imap_host, g:mail_imap_port)
|
||||
call mail#client#send(mail#command#login(username, password))
|
||||
call mail#client#send(mail#command#login(g:mail_imap_login, g:mail_imap_password))
|
||||
call mail#client#send(mail#command#select(mail#client#win#currentDir()))
|
||||
call mail#client#send(mail#command#fetch('1:15', 'BODY[HEADER.FIELDS ("DATE" "FROM" "SUBJECT")]'))
|
||||
call mail#client#send(mail#command#status('INBOX', '["RECENT"]'))
|
||||
|
@ -14,6 +14,9 @@ let g:mail_sending_address = 'wsdjeg@163.com'
|
||||
let g:mail_logger_silent = 0
|
||||
|
||||
let g:mail_imap_host = get(g:, 'mail_imap_host', 'imap.163.com')
|
||||
let g:mail_imap_port = get(g:, 'mail_imap_port', 143)
|
||||
let g:mail_imap_login = get(g:, 'mail_imap_login', '')
|
||||
let g:mail_imap_password = get(g:, 'mail_imap_password', '')
|
||||
|
||||
if !exists('g:mail_directory')
|
||||
let g:mail_directory = expand('~/.vim-mail/')
|
||||
|
@ -4631,6 +4631,7 @@ LAYER OPTIONS
|
||||
1. `imap_host`: set the imap server host
|
||||
2. `imap_port`: set the imap server port
|
||||
3. `imap_login`: set the login of imap server
|
||||
4. `imap_password`: set the password of imap server
|
||||
|
||||
KEY BINDINGS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user