title: Sending e-mail from bash script
body: <p>I am using Ubuntu 18.04 LTS, GNU Mailutils 3.4 and MSMTP 1.6.6 to send an e-mail, containing an attachment, from a Bash script (and/or testing from the command line). I was using BSD-Mailx when the server was running 16.04, but upgrading to 18.04 caused Mailx to not be able to send attachments.</p>
  
  <p>I have tried multiple formats of the <code>mail</code> command in order to pass text to the body of the e-mail, yet they all seem to fail. Some examples:</p>
  
  <pre><code>echo "This is the body of the e-mail" | mail address@example.com -s "This is the subject" -A /file/path/file.txt
  </code></pre>
  
  <p>All I get is the attached file with an empty e-mail.</p>
  
  <pre><code>mail address@example.com -s "This is the subject" -A /file/path/file.txt &lt;&lt;&lt; echo "This is the body of the e-mail"
  </code></pre>
  
  <p>Again, empty e-mail with the attachment.</p>
  
  <p>I have also tried it with the e-mail address at the end of the command, which still just gives an empty e-mail with the attachment.</p>
  
  <p>I have tried several other iterations of the above, such as a single <code>&lt;</code> redirect, <code>|</code> the text at the end of the command, which of course fail, but just trying to guess at the correct format.</p>
  
  <p>Does anyone else have this figured this out?</p>