Linux

Mutt 를 이용한 메일 발송

기억보다는 기록을... 2019. 10. 31. 13:45

html 폼을 사용하여 메일 발송을 위해 이것저것 찾다가 mutt 사용.

일반 텍스트 메일 발송은 mailx 로 사용해도 잘 나감.

 

1. mutt 설치

   # yum install mutt -y

 

2. 설정 파일 생성

   # vi /root/.muttrc 

      . gmail smtp 사용 - < > 부분을 사용자에 맞게 수정

      -------------------------------------------------------------

      set realname = "<first and last name>"

      set from = "<gmail username>@gmail.com"

      set use_from = yes set envelope_from = yes

      set smtp_url = "smtps://<gmail username>@gmail.com@smtp.gmail.com:465/"

      set smtp_pass = "<app password>"

      set imap_user = "<gmail username>@gmail.com"

      set imap_pass = "<app password>"

      set folder = "imaps://imap.gmail.com:993"

      set spoolfile = "+INBOX" set ssl_force_tls = yes

 

      # G to get mail

      bind index G imap-fetch-mail

      set editor = "vim"

      set charset = "utf-8"

      set record = ' '

      -------------------------------------------------------------

 

      . 사용자 인증 없는 smtp 사용 시

      -------------------------------------------------------------

      set smtp_url = "smtp://<smtp server:port>"
      set from="<username@mail>"
      set realname="<first and last name>"

      -------------------------------------------------------------

 

3. 메일 발송

   # mutt -e 'set content_type=text/html' -s '메일제목' '수신자' < html 폼 파일명

 

 

app password 는 구글 로그인 패스워드가 아닌 2차 생성 패스워드임.

https://support.google.com/accounts/answer/185833?hl=ko