问题描述
我正在尝试使用smtp-sink
来捕获mail
命令(var namespace = XmlService.getNamespace("http://www.w3.org/2005/Atom");
var entries = root.getChildren("entry",namespace);
)发送的邮件。
这在我的工作计算机(RHEL7)上正常工作:
mailx
但是,在GitHub Actions(Ubuntu)上,电子邮件仅绕过# Set the env variable `smtp`,which the `mail` command will use:
$ export smtp='localhost:8025'
# Set up the smtp-sink process listening on the port above:
$ smtp-sink -D 'mail_log.txt' -M 1 localhost:8025 1 &
# - will dump to mail_log.txt
# - "-M 1" makes it quit after receiving 1 email
# - the final "1" at the end is the backlog,doesn't matter too much
# - The "&" at the end sets the process up in the background
$ mail -s 'Test' <username> <<< 'This is a test'
$ cat mail_log.txt
X-Client-Addr: ipv6:::xxxx:xxxx:xxxx:xxxx
X-Client-Proto: SMTP
...
Received: from <host> ([ipv6:::xxxx:xxxx:xxxx:xxxx])
by smtp-sink (smtp-sink) with SMTP id xxxxxxxx;
Wed,19 Aug 2020 11:51:51 +0100 (BST)
From: <username>@<host>
To: <username>
Subject: Test
Message-ID: <xxxxxxxx.xxxxxxxxxxxxxxxx%<username>@<host>>
User-Agent: Heirloom mailx 12.5 7/5/10
...
This is a test
并最终进入邮箱。这是工作流程:
smtp-sink
为什么SMTP捕获在GitHub Actions运行器上不起作用?
我还尝试使用Python的smtpd
module代替jobs:
test-smtp-sink:
runs-on: ubuntu-latest
steps:
- run: sudo apt-get update && sudo apt-get install -y bsd-mailx
- run: |
export smtp='localhost:8025'
smtp-sink -D 'mail_log.txt' -M 1 "$smtp" 1 &
mail -s 'Test' runner <<< 'This is a test'
- run: |
mail # Checks mailbox - should be empty but instead contains the test email
cat mail_log.txt # File doesn't exist
:
smtp-sink
再次在我的本地计算机上运行,但在GH Actions上,电子邮件绕过了该电子邮件,并再次出现在邮箱中。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)