code: def gmail_email(self, from_, to, msg):
          
          logging.debug('Emailing from Gmail')
          smtpConn = smtplib.SMTP('smtp.gmail.com', 587)
          smtpConn.ehlo()
          smtpConn.starttls()
          login_response = smtpConn.login(self._credentials['GMAIL_EMAIL'], self._credentials['GMAIL_EMAIL_PASSWORD'])
          
          # if email is of type email.message.Message, flatten and send
          # if anything else, convert to string and try and send
          if isinstance(msg, email.message.Message):
              logging.debug('Flattening MIME to string')
              # If From is already set, overwrite
              msg['From'] = from_
              # If To is string, convert to list and add each to header
              if isinstance(to, str):
                  to = [to]
              for x in to:
                  msg['To'] = x
              msg = msg.as_string()
          else:
              msg = str(msg)
          
          logging.debug(msg.replace('\n', ' '))
          response = smtpConn.sendmail(from_, to, msg)
          logging.info('Response from Gmail: {0}'.format(response))
          smtpConn.quit()
          return response
docs: Send an email from your `gmail`_ account.
          
          .. _gmail: https://mail.google.com/
          
          msg can either be:
          
          * A string, in which case:
          
              * At the first newline (\\n) the string will be split into subject and body
              * If no newline is present, the entire string will be body.
          
          * An `email.message.Message`_ object
          
          .. _email.message.Message: https://docs.python.org/3/library/email.message.html
          
          Login will be performed using stored credentials.
          
          * *stored credential name: GMAIL_EMAIL*
          * *stored credential name: GMAIL_EMAIL_PASSWORD*
          
          :param string from_: The phone number in your twilio account to send the SMS message from. Full international format.        
          :param string to: The email address to send the email to.
          :param body: The content of the email. See above.