8

I use this command to send a logfile with Thunderbird:

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

That launches and shows Thunderbird's prefilled edit-message-window and I have to press the Send button manually.

How can I send email automatically?

screenshot thunderbird

Worthwelle
  • 1,244
  • 1
  • 16
  • 19
Yurij
  • 243
  • 1
  • 4
  • 12

2 Answers2

4

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='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!"

Make it executable:

chmod +x bin/send-mail

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

digikar
  • 576
  • 5
  • 13
  • 1
    You can also send an HTML-formatted email using `message=/path/to/file.html` instead of `body=$output`. For more options, see [Command line arguments](https://kb.mozillazine.org/Command_line_arguments_-_Thunderbird) or type `thunderbird --help`. – bitinerant Dec 23 '21 at 18:24
2

Thunderbird doesn't support automatically sending an email using the command line (i.e. non interactively). This question was answered here - https://support.mozilla.org/en-US/questions/1144493

It suggests you communicate directly with the relevant SMTP server instead of using a mail client like Thunderbird.

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

Sergei Danielian
  • 4,938
  • 4
  • 36
  • 58
Malapeno
  • 21
  • 1
  • 2
    If you are on the command line, one is probably better off with `sendmail` rather than tinkering around with PHP or JavaScript. – Hermann Nov 20 '19 at 15:06