title: Using sendmail from command line
body: <p>I'm trying to write a bash script, to be run by a cron task, which will send me an email under certain circumstances.</p>
  
  <p>In order to try and get sendmail working with my Sendgrid SMTP settings, I've edited the <strong>/etc/postfix/main.cf</strong> file with the following:</p>
  
  <pre><code>smtp_sasl_password_maps = static:&lt;username&gt;:&lt;password&gt;
  smtp_sasl_security_options = noanonymous
  smtp_tls_security_level = may
  smtp_tls_security_level=encrypt
  header_size_limit = 4096000
  relayhost = [smtp.sendgrid.net]:587
  </code></pre>
  
  <p>I restarted postfix using <strong>sudo /etc/init.d/postfix restart</strong></p>
  
  <p>And tried sending an email from the command line using the following command:</p>
  
  <p><strong>sendmail my@email.com &lt; /tmp/email.txt</strong></p>
  
  <p>This results in the following output:</p>
  
  <blockquote>
    <p>You have new mail in /var/mail/ubuntu</p>
  </blockquote>
  
  <p>Why isn't sendgrid sending with my email using the Sendgrid SMTP details I specified in main.cf?</p>
  
  <p><em>Please note, this question relates to sendmail only, I don't want to install other SMTP clients and apps, it needs to work as is.</em></p>