首页 > 代码库 > mutt msmtp 邮件发送功能
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="****_mail@163.com" 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
参 数:
-a<文件> 在邮件中加上附加文件。
-b<地址> 指定密件副本的收信人地址。
-c<地址> 指定副本的收信人地址。
-f<邮件文件> 指定要载入的邮件文件。
-F<配置文件> 指定mutt程序的设置文件,而不读取预设的.muttrc文件。
-h 显示帮助。
-H<邮件草稿> 将指定的邮件草稿送出。
-i<文件> 将指定文件插入邮件内文中。
-m<类型> 指定预设的邮件信箱类型。
-n 不要去读取程序培植文件(/etc/Muttrc)。
-p 在mutt中编辑完邮件后,而不想将邮件立即送出,可将该邮件暂缓寄出。
-R 以只读的方式开启邮件文件。
-s<主题> 指定邮件的主题。
-v 显示mutt的版本信息以及当初编译此文件时所给予的参数。
-x 模拟mailx的编辑方式。
-z 与-f参数一并使用时,若邮件文件中没有邮件即不启动mutt。
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
本文出自 “喜发” 博客,请务必保留此出处http://2678482.blog.51cto.com/2668482/1599031
mutt msmtp 邮件发送功能
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。