脚本中的 Mutt,未指定收件人 - 附件,多个收件人

脚本中的 Mutt,未指定收件人 - 附件,多个收件人

No Recipients Specified我在 bash 脚本中从 Mutt 发送电子邮件时收到错误。我查看了其他论坛问题,并不认为典型的语法错误是这里的问题(最后使用 -a 选项 - 以及收件人等)。我尝试过几种命令安排。

该代码似乎可以从命令行运行,但在脚本中失败,有趣的是,只有当我有多个收件人时它才会失败。这是我如何使用包含地址的字符串变量的问题吗?

语境:

我正在运行 Debian GNU/Linux 7.7(喘息)。

该脚本是从一个服务调用的,该服务与我用于从命令行测试的同一用户运行。我不确定要检查哪些环境变量,但这可能是一个开始的地方,除非脚本对单个收件人运行良好。

相关代码是:

#Email .7z file
EmailTo="[email protected] [email protected]"
echo "$(date '+%m/%d/%Y,%T'): Sending email to $EmailTo..."
echo "Attachment: $myPath/$dateStr.7z"
echo "Subject: $dateStr Daily Data"
mutt -s "$dateStr Daily Data" -a "$myPath/$dateStr.7z" -- $EmailTo <<EOF
Daily data for $dateStr attached.
EOF

我也尝试过类似的变体:

mutt -a "$myPath/$dateStr.7z" <<EOF
To: $EmailTo
Subject: "$dateStr Daily Data"
Daily data for $dateStr attached.
EOF

具有类似的结果。所有变量都可以很好地打印到屏幕上,所以我不知道下一步要尝试什么。

当我添加mutt -v到我的脚本时,它给出:

Mutt 1.5.21 (2010-09-15)
Copyright (C) 1996-2009 Michael R. Elkins and others.
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
Mutt is free software, and you are welcome to redistribute it
under certain conditions; type `mutt -vv' for details.

System: Linux 3.2.0-4-amd64 (x86_64)
ncurses: ncurses 5.9.20110404 (compiled with 5.9)
libidn: 1.25 (compiled with 1.25)
hcache backend: tokyocabinet 1.4.47
Compile options:
-DOMAIN
+DEBUG
-HOMESPOOL  +USE_SETGID  +USE_DOTLOCK  +DL_STANDALONE  +USE_FCNTL
-USE_FLOCK +USE_POP  +USE_IMAP  +USE_SMTP -USE_SSL_OPENSSL
+USE_SSL_GNUTLS  +USE_SASL  +USE_GSS  +HAVE_GETADDRINFO +HAVE_REGCOMP  
-USE_GNU_REGEX +HAVE_COLOR  +HAVE_START_COLOR  +HAVE_TYPEAHEAD  
+HAVE_BKGDSET +HAVE_CURS_SET  +HAVE_META  +HAVE_RESIZETERM
+CRYPT_BACKEND_CLASSIC_PGP  +CRYPT_BACKEND_CLASSIC_SMIME  
+CRYPT_BACKEND_GPGME -EXACT_ADDRESS  -SUN_ATTACHMENT
+ENABLE_NLS  -LOCALES_HACK  +COMPRESSED  +HAVE_WC_FUNCS  
+HAVE_LANGINFO_CODESET  +HAVE_LANGINFO_YESEXPR
+HAVE_ICONV  -ICONV_NONTRANS  +HAVE_LIBIDN  +HAVE_GETSID  +USE_HCACHE
-ISPELL
SENDMAIL="/usr/sbin/sendmail"
MAILPATH="/var/mail"
PKGDATADIR="/usr/share/mutt"
SYSCONFDIR="/etc"
EXECSHELL="/bin/sh"
MIXMASTER="mixmaster"
To contact the developers, please mail to <[email protected]>.
To report a bug, please visit http://bugs.mutt.org/.

misc/am-maintainer-mode
features/ifdef
features/xtitles
features/trash-folder
features/purge-message
features/imap_fast_trash
features/sensible_browser_position
features-old/patch-1.5.4.vk.pgp_verbose_mime
features/compressed-folders
features/compressed-folders.debian
debian-specific/Muttrc
debian-specific/Md.etc_mailname_gethostbyname.diff
debian-specific/use_usr_bin_editor.diff
debian-specific/correct_docdir_in_man_page.diff
debian-specific/dont_document_not_present_features.diff
debian-specific/document_debian_defaults
debian-specific/assumed_charset-compat
debian-specific/467432-write_bcc.patch
debian-specific/566076-build_doc_adjustments.patch
misc/define-pgp_getkeys_command.diff
misc/gpg.rc-paths
misc/smime.rc
upstream/531430-imapuser.patch
upstream/537818-emptycharset.patch
upstream/543467-thread-segfault.patch
upstream/542817-smimekeys-tmpdir.patch
upstream/548577-gpgme-1.2.patch
upstream/553321-ansi-escape-segfault.patch
upstream/568295-references.patch
upstream/547980-smime_keys-chaining.patch
upstream/528233-readonly-open.patch
upstream/228671-pipe-mime.patch
upstream/383769-score-match.patch
upstream/578087-header-strchr.patch
upstream/603288-split-fetches.patch
upstream/537061-dont-recode-saved-attachments.patch
upstream/608706-fix-spelling-errors.patch
upstream/620854-pop3-segfault.patch
upstream/611412-bts-regexp.patch
upstream/624058-gnutls-deprecated-set-priority.patch
upstream/624085-gnutls-deprecated-verify-peers.patch
upstream/584138-mx_update_context-segfault.patch
upstream/619216-gnutls-CN-validation.patch
upstream/611410-no-implicit_autoview-for-text-html.patch
upstream/path_max
upstream/CVE-2014-0467.patch
upstream/771125-CVE-2014-9116.patch
misc/579967-fixes-german-translation.patch
mutt.org

答案1

date | mutt $USER  -s "$subject" -a file1 file2 

对我来说。同样地:

mutt $USER  -s "$subject" -a file1 file2 << EOF
Hello Word
EOF

并且

for $u in User1 User2
do 
date | mutt $u -s "message to $u" -a file1.jpg file2.txt
done

相关内容