Mutt 无法从 ci/cd 管道发送电子邮件

Mutt 无法从 ci/cd 管道发送电子邮件

Mutt 默默地无法发送电子邮件。没有错误或失败。但有时邮件发送成功,有时却发送失败。

这就是我在一项任务中安装所有必需的可安装文件/库的方式。

sudo apt-get update
sudo apt install snapd
sudo snap install okular
sudo apt install mailutils
sudo apt install mutt

在另一项任务中,我发送这样的电子邮件:

url=https://dev.azure.com/xyz/project/_build/results?buildId=$(Build.BuildId)


echo -e "$url"

mutt -v 

echo -e "Hello All,\n\n Please find inline as well as attached the elaborative test results which $(Agent.JobStatus) and generated  \n\nRegards\nQA Team\n\nLink to Azure DevOps Pipeline Build : $url-- [email protected]

以下是发送邮件的日志。我在这里没有看到任何错误。

2023-06-13T06:34:21.9114531Z ##[section]Starting: Email with E2E report and logs using utils
2023-06-13T06:34:21.9118245Z ==============================================================================
2023-06-13T06:34:21.9118373Z Task         : Bash
2023-06-13T06:34:21.9118437Z Description  : Run a Bash script on macOS, Linux, or Windows
2023-06-13T06:34:21.9118539Z Version      : 3.214.0
2023-06-13T06:34:21.9118605Z Author       : Microsoft Corporation
2023-06-13T06:34:21.9118684Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
2023-06-13T06:34:21.9118799Z ==============================================================================
2023-06-13T06:34:22.0517617Z Generating script.
2023-06-13T06:34:22.0538699Z ========================== Starting Command Output ===========================
2023-06-13T06:34:22.0549802Z [command]/usr/bin/bash /home/vsts/work/_temp/8c145d8d-536a-4543-addb-40c24c02f85d.sh
2023-06-13T06:34:22.0625138Z https://dev.azure.com/xyz/project/_build/results?buildId=5209788
2023-06-13T06:34:22.0656911Z Mutt 1.13.2 (2019-12-18)
2023-06-13T06:34:22.0657459Z Copyright (C) 1996-2016 Michael R. Elkins and others.
2023-06-13T06:34:22.0658162Z Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
2023-06-13T06:34:22.0658578Z Mutt is free software, and you are welcome to redistribute it
2023-06-13T06:34:22.0658981Z under certain conditions; type `mutt -vv' for details.
2023-06-13T06:34:22.0659300Z 
2023-06-13T06:34:22.0660934Z System: Linux 5.15.0-1038-azure (x86_64)
2023-06-13T06:34:22.0661328Z ncurses: ncurses 6.2.20200212 (compiled with 6.2)
2023-06-13T06:34:22.0661631Z libidn: 1.33 (compiled with 1.33)
2023-06-13T06:34:22.0734866Z hcache backend: tokyocabinet 1.4.48
2023-06-13T06:34:22.0735064Z 
2023-06-13T06:34:22.0735270Z Compiler:
2023-06-13T06:34:22.0735584Z Using built-in specs.
2023-06-13T06:34:22.0735779Z COLLECT_GCC=gcc
2023-06-13T06:34:22.0736064Z COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
2023-06-13T06:34:22.0736360Z OFFLOAD_TARGET_NAMES=nvptx-none:hsa
2023-06-13T06:34:22.0736561Z OFFLOAD_TARGET_DEFAULT=1
2023-06-13T06:34:22.0736984Z Target: x86_64-linux-gnu
2023-06-13T06:34:22.0738676Z Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
2023-06-13T06:34:22.0739695Z Thread model: posix
2023-06-13T06:34:22.0739956Z gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) 
2023-06-13T06:34:22.0740049Z 
2023-06-13T06:34:22.0741633Z Configure options: '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=\${prefix}/include' '--mandir=\${prefix}/share/man' '--infodir=\${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-silent-rules' '--libdir=\${prefix}/lib/x86_64-linux-gnu' '--libexecdir=\${prefix}/lib/x86_64-linux-gnu' '--disable-maintainer-mode' '--disable-dependency-tracking' '--with-mailpath=/var/mail' '--enable-compressed' '--enable-debug' '--enable-fcntl' '--enable-hcache' '--enable-gpgme' '--enable-imap' '--enable-smtp' '--enable-pop' '--enable-sidebar' '--enable-nntp' '--enable-dotlock' '--disable-fmemopen' '--with-curses' '--with-gnutls' '--with-gss' '--with-idn' '--with-mixmaster' '--with-sasl' '--without-gdbm' '--without-bdb' '--without-qdbm' '--with-tokyocabinet' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/mutt-30uNgF/mutt-1.13.2=. -fstack-protector-strong -Wformat -Werror=format-security' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
2023-06-13T06:34:22.0742559Z 
2023-06-13T06:34:22.0742969Z Compilation CFLAGS: -Wall -pedantic -Wno-long-long -g -O2 -fdebug-prefix-map=/build/mutt-30uNgF/mutt-1.13.2=. -fstack-protector-strong -Wformat -Werror=format-security
2023-06-13T06:34:22.0743153Z 
2023-06-13T06:34:22.0743297Z Compile options:
2023-06-13T06:34:22.0743479Z -DOMAIN
2023-06-13T06:34:22.0743612Z +DEBUG
2023-06-13T06:34:22.0743899Z -HOMESPOOL  +USE_SETGID  +USE_DOTLOCK  +DL_STANDALONE  +USE_FCNTL  -USE_FLOCK   
2023-06-13T06:34:22.0744106Z +USE_POP  +USE_IMAP  +USE_SMTP  
2023-06-13T06:34:22.0744394Z -USE_SSL_OPENSSL  +USE_SSL_GNUTLS  +USE_SASL  +USE_GSS  +HAVE_GETADDRINFO  
2023-06-13T06:34:22.0744658Z +HAVE_REGCOMP  -USE_GNU_REGEX  
2023-06-13T06:34:22.0744866Z +HAVE_COLOR  +HAVE_START_COLOR  +HAVE_TYPEAHEAD  +HAVE_BKGDSET  
2023-06-13T06:34:22.0745086Z +HAVE_CURS_SET  +HAVE_META  +HAVE_RESIZETERM  +HAVE_FUTIMENS  
2023-06-13T06:34:22.0745324Z +CRYPT_BACKEND_CLASSIC_PGP  +CRYPT_BACKEND_CLASSIC_SMIME  +CRYPT_BACKEND_GPGME  
2023-06-13T06:34:22.0745584Z -EXACT_ADDRESS  -SUN_ATTACHMENT  
2023-06-13T06:34:22.0745903Z +ENABLE_NLS  -LOCALES_HACK  +HAVE_WC_FUNCS  +HAVE_LANGINFO_CODESET  +HAVE_LANGINFO_YESEXPR  
2023-06-13T06:34:22.0746252Z +HAVE_ICONV  -ICONV_NONTRANS  +HAVE_LIBIDN  -HAVE_LIBIDN2  +HAVE_GETSID  +USE_HCACHE  
2023-06-13T06:34:22.0746476Z +USE_SIDEBAR  +USE_COMPRESSED  +USE_INOTIFY  
2023-06-13T06:34:22.0746674Z -ISPELL
2023-06-13T06:34:22.0746837Z SENDMAIL="/usr/sbin/sendmail"
2023-06-13T06:34:22.0746993Z MAILPATH="/var/mail"
2023-06-13T06:34:22.0747156Z PKGDATADIR="/usr/share/mutt"
2023-06-13T06:34:22.0747315Z SYSCONFDIR="/etc"
2023-06-13T06:34:22.0747487Z EXECSHELL="/bin/sh"
2023-06-13T06:34:22.0747643Z MIXMASTER="mixmaster"
2023-06-13T06:34:22.0747771Z 
2023-06-13T06:34:22.0748027Z To contact the developers, please mail to <[email protected]>.
2023-06-13T06:34:22.0748255Z To report a bug, please contact the Mutt maintainers via gitlab:
2023-06-13T06:34:22.0748463Z     https://gitlab.com/muttmua/mutt/issues
2023-06-13T06:34:22.0748544Z 
2023-06-13T06:34:22.2419708Z ##[section]Finishing: Email with E2E 

使用 utils 报告和日志

可能是什么原因?设置在 Ubuntu 20.04 上

答案1

在您的示例中,您没有发送包含 mutt 的电子邮件,您正在运行mutt -v(显示 mutt 的版本和编译详细信息),然后您正在运行echo.

如果你想用 mutt 发送消息,你可以这样做:

mutt -s "subject" [email protected] <<__EOF__
Hello All,

Please find inline as well as attached the elaborative test results which $(Agent.JobStatus) and generated

Regards
QA Team

Link to Azure DevOps Pipeline Build : $url

__EOF__

您可以使用echoprintf或其他任何方式将消息通过管道传输到 中mutt,但由于消息中嵌入了多个换行符,因此使用heredoc更容易。

man mutt有关 mutt 命令行选项的更多详细信息,请参阅参考资料 - 例如,您可以使用-a filenameMIME 附加文件、-i filename将文件包含在消息正文中、-c用于 CC 和-bBCC。

相关内容