title: Executing shell mail command using python
body: <p>I have used the following code to send an email as suggested in one of the post on the similar topic. But the mail has not been sent. Any suggestions?</p>
  
  <pre><code>import subprocess
  recipient = 'xxxxx@gmail.com'
  subject = 'test'
  body = 'testing mail through python'
  def send_message(recipient, subject, body):
      process = subprocess.Popen(['mail', '-s', subject, recipient],
                                 stdin=subprocess.PIPE)
      process.communicate(body)
  
  print("sent the email")
  </code></pre>