Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 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

like image 717
Yurij Avatar asked Aug 09 '17 11:08

Yurij


People also ask

Can you send email from command line?

sendmail Command Sendmail is one of the most popular SMTP servers in Linux. You can easily send emails directly from the command line using the sendmail command. To route the information, the sendmail command makes use of the network configured on your system.

How do I start Thunderbird from command line?

However I created shortcuts on the desktop - here's an example Start in: "C:\Program Files\Mozilla Thunderbird" Target: "C:\Program Files\Mozilla Thunderbird\thunderbird.exe" -P "default" and it works!


2 Answers

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.

like image 181
digikar Avatar answered Oct 21 '22 22:10

digikar


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

like image 2
Malapeno Avatar answered Oct 21 '22 22:10

Malapeno