如何从命令行编写和发送Thunderbird中的电子邮件?

时间:2017-08-09 11:07:15

标签: ubuntu command-line-interface thunderbird

我使用此命令发送带有thunderbird的日志文件

thunderbird -compose "subject='test',to='test@mail.test',body=$output,attachment='/home/test/scan.log'"

启动并显示thunderbird prefilled edit-message-window,我必须手动按下发送按钮 如何自动发送电子邮件?screenshot thunderbird

2 个答案:

答案 0 :(得分:2)

实际上,可以使用xdotool。虽然不是“适当的”,但有可能。

您可以(进行修改以适合您的目的)并将其保存到〜/ bin / send-mail

#!/bin/bash

output='testing'

thunderbird -compose "subject='test mail',to='test@mail.com',body=$output" &
sleep 2                  # Wait for the window to open
xdotool mousemove 55 105 # Find the exact position of the send button manually
sleep 0.25               # Might not be needed
xdotool click 1          # Click it
echo "Done!"

使其可执行:

chmod +x bin/send-mail

另外,将其添加到您的cron作业中。但这肯定是有风险的。

答案 1 :(得分:1)

Thunderbird不支持使用命令行自动发送电子邮件(即非交互式)。这个问题在这里得到了解答 - https://support.mozilla.org/en-US/questions/1144493

它建议您直接与相关的SMTP服务器通信,而不是使用像Thunderbird这样的邮件客户端。

可能使用PHP - http://www.inmotionhosting.com/support/website/sending-email-from-site/using-the-php-mail-function-to-send-emails