天天看點

mutt msmtp 郵件發送功能

發送郵件用戶端:  Msmtp下載下傳

Msmtp是一款專門負責郵件發送的用戶端軟體,基于GPL釋出。支援TLS/SSL、DNS模式、IPv6、伺服器端認證、多使用者等特性。

郵件打包: Mutt下載下傳

Msmtp - Ubuntu編譯 

./configure --sysconfdir=/etc  
make  
make install      

Msmtp - 配置

  • 編譯的時候加上了--sysconfdir=/etc,那麼全局的配置檔案就在/etc下面,名為Msmtprc,
    • 也可以 msmtp -C msmtprc 指定配置檔案
    • 如果直接 ./configure 編譯時,".msmtprc" 為使用者目錄(~/) 是 "/usr/local/etc/msmtprc" 
  • 配置,得去 163 上注冊個郵箱 
account default
host smtp.163.com  #發送的郵件伺服器
port 25  #端口号
from ****@@163.com #用于發送的郵箱
auth login
tls off
user ****@163.com  #郵箱使用者名
password ***       #郵箱密碼,這裡可是明文的,如果你覺得不安全可以把檔案改為600屬性
logfile /var/log/mmlog   #日志檔案      

Msmtp -測試 

msmtp -t   # -t 指定收件人  msmtp 是接收鍵盤輸入
to: ****@qq.com  # 收件人
subject: 郵件測試  # 主題
#空行
這是郵件内容
#ctrl+d 結束
msmtp: log info was: host=smtp.163.com tls=off auth=on user=****@163.com 
from=****@163.com recipients=****@qq.com mailsize=125 smtpstatus=250 
smtpmsg='250 2.0.0 OK 0844c3e6-3f85-4946-b33c-bac1bbfd1b96' exitcode=EX_OK      

Msmtp -調試(-d)

msmtp -d -t   
to: ****@qq.com
subject: 郵件測試 
ignoring system configuration file /usr/local/etc/msmtprc: No such file or directory
loaded user configuration file /home/****/.msmtprc
falling back to default account
using account default from /home/****/.msmtprc
host                  = smtp.163.com
port                  = 25
timeout               = off
protocol              = smtp
domain                = localhost
auth                  = LOGIN
user                  = ****@163.com
password              = *
passwordeval          = (not set)
ntlmdomain            = (not set)
tls                   = off
tls_starttls          = on
tls_trust_file        = (not set)
tls_crl_file          = (not set)
tls_fingerprint       = (not set)
tls_key_file          = (not set)
tls_cert_file         = (not set)
tls_certcheck         = on
tls_force_sslv3       = off
tls_min_dh_prime_bits = (not set)
tls_priorities        = (not set)
auto_from             = off
maildomain            = (not set)
from                  = ****@163.com
dsn_notify            = (not set)
dsn_return            = (not set)
keepbcc               = off
logfile               = /var/log/mmlog
syslog                = (not set)
aliases               = (not set)
reading recipients from the command line and the mail
<-- 220 hz-b-163smtp2.163.com SMTP Server for Netease [466] 25c8afc4-d57e-4c39-8409-1679ff504de2
--> EHLO localhost
<-- 250-hz-b-163smtp2.163.com
<-- 250-mail
<-- 250-PIPELINING
<-- 250-8BITMIME
<-- 250-AUTH LOGIN PLAIN
<-- 250-AUTH=LOGIN PLAIN
<-- 250 STARTTLS 25c8afc4-d57e-4c39-8409-1679ff504de2
--> AUTH LOGIN
<-- 334 VXNlcm5hbWU6 25c8afc4-d57e-4c39-8409-1679ff504de2
--> enFlY2dfbWFpbEAxNjMuY29t
<-- 334 UGFzc3dvcmQ6 25c8afc4-d57e-4c39-8409-1679ff504de2
--> YWJjZC4xMjM0
<-- 235 OK, go ahead (#2.0.0) 25c8afc4-d57e-4c39-8409-1679ff504de2
--> MAIL FROM:<****@163.com>
--> RCPT TO:<****@qq.com>
--> DATA
<-- 250 2.0.0 OK 25c8afc4-d57e-4c39-8409-1679ff504de2
<-- 250 2.0.0 OK 25c8afc4-d57e-4c39-8409-1679ff504de2
<-- 354 Start mail input; end with <CRLF>.<CRLF> 25c8afc4-d57e-4c39-8409-1679ff504de2
--> to: ****@qq.com
--> subject: 郵件測試 
--> 
--> 
--> 
這是郵件内容
--> 這是郵件内容
--> 
--> 
--> 
--> .
<-- 250 2.0.0 OK 25c8afc4-d57e-4c39-8409-1679ff504de2
--> QUIT
<-- 221 2.0.0 Bye 25c8afc4-d57e-4c39-8409-1679ff504de2
msmtp: cannot log to /var/log/mmlog: cannot open: Permission denied
msmtp: log info was: host=smtp.163.com tls=off auth=on user=****@163.com 
from=****@163.com recipients=****@qq.com mailsize=66 smtpstatus=250 
smtpmsg='250 2.0.0 OK 25c8afc4-d57e-4c39-8409-1679ff504de2' exitcode=EX_OK      

Msmtp -應用

 ./msmtp -C msmtprc  -t < mail.txt   # -C 指定 msmtp 的配置檔案
cat ./mail.txt
to: ***@qq.com
subject: 主題内容...      

Mutt - Ubuntu編譯 

./configure --sysconfdir=/etc  
make  
make install      

Mutt - 配置

cat /etc/Muttrc
set sendmail="/usr/local/bin/msmtp"
set from="****[email protected]"
set use_from=yes 
set realname="****-ecg" 
set editor="vi"      

Mutt - 調試(-D)

mutt -D
abort_nosubject=ask-yes
abort_unmodified=yes
alias_file="~/.muttrc"
alias_format="%4n %2f %t %-10a   %r"
allow_8bit is set
allow_ansi is unset
arrow_cursor is unset
ascii_chars is unset
askbcc is unset
askcc is unset
assumed_charset=""
attach_charset=""
attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
attach_sep="\n"
attach_split is set
attribution="On %d, %n wrote:"
auto_tag is unset
autoedit is unset
beep is set
beep_new is unset
bounce=ask-yes
bounce_delivered is set
braille_friendly is unset
charset="utf-8"
check_mbox_size is unset
check_new is set
collapse_unread is set
compose_format="-- Mutt: Compose  [Approx. msg size: %l   Atts: %a]%>-"
config_charset=""
confirmappend is set
confirmcreate is set
connect_timeout=30
content_type="text/plain"
copy=yes
crypt_autoencrypt is unset
crypt_autopgp is set
crypt_autosign is unset
crypt_autosmime is set
crypt_replyencrypt is set
crypt_replysign is unset
crypt_replysignencrypted is unset
crypt_timestamp is set
crypt_use_gpgme is unset
crypt_use_pka is unset
crypt_verify_sig=yes
date_format="!%a, %b %d, %Y at %I:%M:%S%p %Z"
default_hook="~f %s !~P | (~P ~C %s)"
delete=ask-yes
delete_untag is set
digest_collapse is set
display_filter=""
dsn_notify=""
dsn_return=""
duplicate_threads is set
edit_headers is unset
editor="vi"
encode_from is unset
envelope_from_address=""
escape="~"
fast_reply is unset
fcc_attach=yes
fcc_clear is unset
folder="~/Mail"
folder_format="%2C %t %N %F %2l %-8.8u %-8.8g %8s %d %f"
followup_to is set
force_name is unset
forward_decode is set
forward_decrypt is set
forward_edit=yes
forward_format="[%a: %s]"
forward_quote is unset
from=""
gecos_mask="^[^,]*"
hdrs is set
header is unset
help is set
hidden_host is unset
hide_limited is unset
hide_missing is set
hide_thread_subject is set
hide_top_limited is unset
hide_top_missing is set
history=10
history_file="~/.mutthistory"
honor_disposition is unset
honor_followup_to=yes
hostname="ubuntu.localdomain"
ignore_linear_white_space is unset
ignore_list_reply_to is unset
implicit_autoview is unset
include=ask-yes
include_onlyfirst is unset
indent_string="> "
index_format="%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s"
ispell="ispell"
keep_flagged is unset
locale="C"
mail_check=5
mail_check_recent is set
mailcap_path="~/.mailcap:/usr/local/share/mutt/mailcap:/usr/local/etc/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap"
mailcap_sanitize is set
maildir_trash is unset
mark_old is set
markers is set
mask="!^\\.[^.]"
mbox="~/mbox"
mbox_type=mbox
menu_context=0
menu_move_off is set
menu_scroll is unset
message_format="%s"
meta_key is unset
metoo is unset
mh_purge is unset
mh_seq_flagged="flagged"
mh_seq_replied="replied"
mh_seq_unseen="unseen"
mime_forward=no
mime_forward_decode is unset
mime_forward_rest=yes
move=no
narrow_tree is unset
pager="builtin"
pager_context=0
pager_format="-%Z- %C/%m: %-20.20n   %s%*  -- (%P)"
pager_index_lines=0
pager_stop is unset
pgp_auto_decode is unset
pgp_autoinline is unset
pgp_check_exit is set
pgp_clearsign_command=""
pgp_decode_command=""
pgp_decrypt_command=""
pgp_encrypt_only_command=""
pgp_encrypt_sign_command=""
pgp_entry_format="%4n %t%f %4l/0x%k %-4a %2c %u"
pgp_export_command=""
pgp_getkeys_command=""
pgp_good_sign=""
pgp_ignore_subkeys is set
pgp_import_command=""
pgp_list_pubring_command=""
pgp_list_secring_command=""
pgp_long_ids is unset
pgp_mime_auto=ask-yes
pgp_replyinline is unset
pgp_retainable_sigs is unset
pgp_show_unusable is set
pgp_sign_as=""
pgp_sign_command=""
pgp_sort_keys=address
pgp_strict_enc is set
pgp_timeout=300
pgp_use_gpg_agent is unset
pgp_verify_command=""
pgp_verify_key_command=""
pipe_decode is unset
pipe_sep="\n"
pipe_split is unset
post_indent_string=""
postpone=ask-yes
postponed="~/postponed"
print=ask-no
print_command="lpr"
print_decode is set
print_split is unset
prompt_after is set
query_command=""
query_format="%4c %t %-25.25a %-25.25n %?e?(%e)?"
quit=yes
quote_regexp="^([ \t]*[|>:}#])+"
read_inc=10
read_only is unset
realname="xianhua"
recall=ask-yes
record="~/sent"
reflow_text is set
reflow_wrap=78
reply_regexp="^(re([\\[0-9\\]+])*|aw):[ \t]*"
reply_self is unset
reply_to=ask-yes
resolve is set
reverse_alias is unset
reverse_name is unset
reverse_realname is set
rfc2047_parameters is unset
save_address is unset
save_empty is set
save_history=0
save_name is unset
score is set
score_threshold_delete=-1
score_threshold_flag=9999
score_threshold_read=-1
search_context=0
send_charset="us-ascii:iso-8859-1:utf-8"
sendmail="/usr/sbin/sendmail -oem -oi"
sendmail_wait=0
shell="/bin/bash"
sig_dashes is set
sig_on_top is unset
signature="~/.signature"
simple_search="~f %s | ~s %s"
sleep_time=1
smart_wrap is set
smileys="(>From )|(:[-^]?[][)(><}{|/DP])"
smime_ask_cert_label is set
smime_ca_location=""
smime_certificates=""
smime_decrypt_command=""
smime_decrypt_use_default_key is set
smime_default_key=""
smime_encrypt_command=""
smime_encrypt_with=""
smime_get_cert_command=""
smime_get_cert_email_command=""
smime_get_signer_cert_command=""
smime_import_cert_command=""
smime_is_default is unset
smime_keys=""
smime_pk7out_command=""
smime_sign_command=""
smime_sign_opaque_command=""
smime_timeout=300
smime_verify_command=""
smime_verify_opaque_command=""
sort=date
sort_alias=alias
sort_aux=date
sort_browser=alpha
sort_re is set
spam_separator=","
spoolfile="/var/mail/gdyshi"
status_chars="-*%A"
status_format="-%r-Mutt: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---"
status_on_top is unset
strict_threads is unset
suspend is set
text_flowed is unset
thorough_search is set
thread_received is unset
tilde is unset
time_inc=0
timeout=600
tmpdir="/tmp"
to_chars=" +TCFL"
uncollapse_jump is unset
use_8bitmime is unset
use_domain is set
use_envelope_from is unset
use_from is set
user_agent is set
visual="vi"
wait_key is set
weed is set
wrap=0
wrap_headers=78
wrap_search is set
wrapmargin=0
write_bcc is set
write_inc=10      

Mutt -幫助

mutt -help
Mutt 1.5.23 (2014-03-12)
usage: mutt [<options>] [-z] [-f <file> | -yZ]
       mutt [<options>] [-x] [-Hi <file>] [-s <subj>] [-bc <addr>] [-a <file> [...] --] <addr> [...]
       mutt [<options>] [-x] [-s <subj>] [-bc <addr>] [-a <file> [...] --] <addr> [...] < message
       mutt [<options>] -p
       mutt [<options>] -A <alias> [...]
       mutt [<options>] -Q <query> [...]
       mutt [<options>] -D
       mutt -v[v]
options:
  -A <alias>    expand the given alias
  -a <file> [...] --    attach file(s) to the message (附件)
        the list of files must be terminated with the "--" sequence
  -b <address>    specify a blind carbon-copy (BCC) address
  -c <address>    specify a carbon-copy (CC) address
  -D        print the value of all variables to stdout
  -e <command>    specify a command to be executed after initialization
  -f <file>    specify which mailbox to read
  -F <file>    specify an alternate muttrc file  (指定配置檔案)
  -H <file>    specify a draft file to read header and body from
  -i <file>    specify a file which Mutt should include in the body
  -m <type>    specify a default mailbox type
  -n        causes Mutt not to read the system Muttrc
  -p        recall a postponed message
  -Q <variable>    query a configuration variable
  -R        open mailbox in read-only mode
  -s <subj>    specify a subject (must be in quotes if it has spaces)
  -v        show version and compile-time definitions
  -x        simulate the mailx send mode
  -y        select a mailbox specified in your `mailboxes' list
  -z        exit immediately if there are no messages in the mailbox
  -Z        open the first folder with new message, exit immediately if none
  -h        this help message      

Mutt - 應用

# 發送郵件 -s 主題 -a 附件 -c 收件人 < 檔案(郵件内容)
mutt -s "send mail" -a /home/****/.muttrc -c ****@qq.com < ./mail.txt 
# 這是的郵件内容 "TEST"
echo "TEST" | mutt -s "send mail" -a /home/****/.muttrc  -c ****@qq.com      

Mutt -交叉編譯

export PATH=$PATH:/usr/local/ti-sdk-am335x-evm/linux-devkit/bin
export CC=arm-arago-linux-gnueabi-gcc
export CXX=arm-arago-linux-gnueabi-g++
./configure --host=arm-arago-linux-gnueabi      

繼續閱讀