Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #VAR
  4. mutt_conf=/tmp/.conf
  5. dirmail=/home/$USER/mail
  6.  
  7. # check file
  8. function check_file(){
  9. if [ -f $mutt_conf ]; then
  10. echo "the $mutt_conf and $dirmail files were not deleted"
  11. else
  12. echo "the $mutt_conf and $dirmail files have been deleted"
  13. fi
  14. }
  15.  
  16. # create mail directory
  17. function foldermail(){
  18. if [ -e /home/$USER/mail ]
  19. then
  20. echo " the $dirmail directory already exists"
  21. else
  22. echo " the $dirmail directory does not exist and has been created"
  23. mkdir /home/$USER/mail
  24. fi
  25. }
  26.  
  27.  
  28. # menu del
  29. function del_menu(){
  30. title="want to delete the file $mutt_conf and directory $dirmail that were created"
  31. prompt="Select: "
  32. options=("Yes" "No")
  33. echo "$title"
  34. PS3="$prompt"
  35. select opt in "${options[@]}" "Quit/Cancel"; do
  36. case "$REPLY" in
  37. 1 ) echo -e "YES: " ; shred -u -z -n 20 $mutt_conf ; rm -r $dirmail ; check_file ; read -p "Press ENTER to exit..." xenter ; clear ; reset ; exit ;;
  38. 2 ) echo -e "NO: " ; check_file ; read -p "Press ENTER to exit..." xenter ; clear ; reset ; exit ;;
  39. $(( ${#options[@]}+1 )) ) clear; reset ; clear ; reset ; exit;;
  40. *) echo "Invalid option. Try another one.";continue;;
  41. esac
  42. done
  43. return
  44. }
  45.  
  46. # parameters
  47. while [ -n "$1" ]
  48. do
  49. case "$1" in
  50. -g)
  51. mutt_conf(){
  52. cat > /tmp/.conf <<END
  53.  
  54. set mbox_type=maildir
  55. set mbox="~/mail/inbox/"
  56. set spoolfile="~/mail/inbox/"
  57. set folder="~/mail/"
  58. set record="~/mail/sent/"
  59. set postponed="~/mail/postponed/"
  60.  
  61. # Cont Gmail.
  62. set from = "$xlogin@gmail.com"
  63. set realname = "$rname"
  64. set imap_user = "$xlogin@gmail.com"
  65. set imap_pass = "$xpass"
  66.  
  67. # Editor.
  68. set editor=vim
  69.  
  70. # folder IMAP.
  71. set folder = "imaps://imap.gmail.com:993"
  72. set spoolfile = "+INBOX"
  73. set postponed ="+[Gmail]/Drafts"
  74.  
  75. # folder Local.
  76. set header_cache =~/.mutt/cache/headers
  77. set message_cachedir =~/.mutt/cache/bodies
  78. set certificate_file =~/.mutt/certificates
  79.  
  80. # SMTP Config.
  81. set smtp_url = "smtp://$xlogin@smtp.gmail.com:587/"
  82. set smtp_pass = "$xpass"
  83.  
  84. END
  85. }
  86. clear ; reset ; foldermail ; echo -e "### TMUTT - GMAIL ###" ;
  87. read -ep "Login: " xlogin ;
  88. echo -e "Email: $xlogin@gmail.com" ;
  89. read -ep "Real name: " rname ;
  90. echo -e "Password:" ;
  91. read -s xpass ;
  92. mutt_conf ; mutt -F $mutt_conf ; del_menu ;
  93. ;;
  94. -s)
  95. mutt_conf(){
  96. cat > /tmp/.conf <<END
  97.  
  98. set mbox_type=maildir
  99. set mbox="~/mail/inbox/"
  100. set spoolfile="~/mail/inbox/"
  101. set folder="~/mail/"
  102. set record="~/mail/sent/"
  103. set postponed="~/mail/postponed/"
  104.  
  105. # Cont Gmail.
  106. set from = "$xemail"
  107. set realname = "$rname"
  108. set imap_user = "$xemail"
  109. set imap_pass = "$xpass"
  110.  
  111. # Editor.
  112. set editor=vim
  113.  
  114. # folder IMAP.
  115. set folder = "imaps://$ximap:$xportimap"
  116. set spoolfile = "+INBOX"
  117. set postponed ="+[Gmail]/Drafts"
  118.  
  119. # folder Local.
  120. set header_cache =~/.mutt/cache/headers
  121. set message_cachedir =~/.mutt/cache/bodies
  122. set certificate_file =~/.mutt/certificates
  123.  
  124. # SMTP Config.
  125. set smtp_url = "smtp://$xlogin@$xsmtp:$xportsmtp/"
  126. set smtp_pass = "$xpass"
  127.  
  128. END
  129. }
  130. clear ; reset ; foldermail ; echo -e "### TMUTT - SMTP/IMAP ###" ;
  131. read -ep "Login: " xlogin ;
  132. read -ep "Email: " xemail ;
  133. read -ep "IMAP: " ximap
  134. read -ep "Port-IMAP: " xportimap
  135. read -ep "SMTP: " xsmtp
  136. read -ep "Port-SMTP: " xportsmtp
  137. read -ep "Real name: " rname ;
  138. echo -e "Password:" ;
  139. read -s xpass ;
  140. mutt_conf ; mutt -F $mutt_conf ; del_menu ;
  141. ;;
  142. -h) clear ; reset ; echo "### TMUTT v1b - HELP ###"
  143. echo "--Options"
  144. echo "-s |--SMTP - configure smtp and port to send email"
  145. echo "-g |--GMAIL SMTP - uses smtp and port google default to send emails "
  146. echo "-c |--LOAD CONFIG - loads a configuration file mutt"
  147. echo "-cls |--DELETE CONFIGURATION - deletes all configuration files"
  148. echo "-------------------------"
  149. echo "**IMPORTANT INFORMATION**"
  150. echo "**this Shell Script use the package mutt**"
  151. echo "-------------------------"
  152. echo "----by Seehrum - 2018----";
  153. ;;
  154. -c) clear ; reset ; echo -e "### TMUTT - CONFIG ###" ; read -ep "Path conf: " xpath ; mutt -F $xpath ;
  155. ;;
  156. -cls) shred -u -z -n 20 $mutt_conf ; rm -r $dirmail ; clear ; reset ; echo -e "the configuration files have been deleted" ;
  157. ;;
  158. -*) echo "tmutt: invalid command - for help use the -h parameter"
  159. ;;
  160. *) echo "tmutt: invalid command - for help use the -h parameter"
  161. esac
  162. shift
  163. exit 0
  164. done
  165. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement