Sending mail from command line using Mutt

I use this to attach reports (pdfs, etc) to emails in my scripts. Small Perl snippet:

system("/usr/bin/mutt -i $file_with_body_content -a $file_to_attach -s "Some Random Report $report_date" $mailto < /dev/null");

And since this has now bitten me twice, make sure that there are no variables with carriage returns at the end. In my case, both times I forgot to chomp($report_date) and could not figure out why the attachments were displaying inline instead of as proper attachments when I received the email.

1 thought on “Sending mail from command line using Mutt

Leave a Comment