title: How to send email attachments using python httplib2 with Mailgun
body: <p>I am using httplib2 with the Mailgun API to send an email attachment which I downloaded using the Google Drive, the email is sending but without attachments.. below is my code..</p>
  
  <pre><code>DRIVE = discovery.build('drive', 'v3', http=http_auth)
  
          request = DRIVE.files().export_media(fileId=file_id, mimeType='application/pdf')
  
          fh = io.BytesIO()
          downloader = MediaIoBaseDownload(fh, request)
  
          done = False
          while done is False:
              status, done = downloader.next_chunk()
              logging.info("Download %d%%." % int(status.progress() * 100))
  
          messages = {
              "from": sender,
              "to": recipient,
              "subject": 'Attachment Mail from Mailgun',
              "text": 'Testing',
              "attachment": fh.getvalue()
          }
  
           url = URL
  
          data = {
              "from": messages['from'],
              "to": messages['to'],
              "subject": messages['subject'],
              "text": messages['text'],
              "attachment": messages['attachment']
          }
  
          pl = urllib.urlencode(data)
  
          http = httplib2.Http()
          http.add_credentials('api', API)
  
          resp, content = http.request(
              url, 'POST', pl,
              headers={"Content-Type": "application/x-www-form-urlencoded"})
  </code></pre>