How can I compose and send email in Thunderbird from commandline?

Yurij picture Yurij · Aug 9, 2017 · Viewed 12.3k times · Source

I use this command to send a logfile with thunderbird

thunderbird -compose "subject='test',to='[email protected]',body=$output,attachment='/home/test/scan.log'"

that launchs and shows thunderbird prefilled edit-message-window and i have to press send button manually How it is possible to send email automatically?screenshot thunderbird

Answer

digikar picture digikar · Jul 1, 2018

Actually, it is possible, using xdotool. Though not "proper", it is possible.

You can (modify to suit your purpose) and save this to ~/bin/send-mail

#!/bin/bash

output='testing'

thunderbird -compose "subject='test mail',to='[email protected]',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!"

Make it executable:

chmod +x bin/send-mail

Addionally, add it to your cron job. But this sure can be risky.