title: Why is the email not sending to the recipient?
body: <p>This is the code I have running, which is supposedly working totally fine, but it is not actually sending the email to the address I specify. It does not have anything to do with the CSV because I have another script doing the same thing and working just fine. The problem is that the email is being placed in the senders inbox... which is weird.</p>
  
  <p>I would rather use this script since it's nicely object oriented and it has all the proper subject fields, etc.</p>
  
  <pre><code>import smtplib
  import pandas as pd
  
  
  class Gmail(object):
      def __init__(self, email, password, recepient):
          self.email = email
          self.password = password
          self.recepient = recepient
          self.server = 'smtp.gmail.com'
          self.port = 465
          session = smtplib.SMTP_SSL(self.server, self.port)        
          session.ehlo
          session.login(self.email, self.password)
          self.session = session
          print('Connected to Gmail account successfully.')
  
      def send_message(self, subject, body):
          headers = [
              "From: " + self.email,
              "Subject: " + subject,
              "To: " + self.recepient,
              "MIME-Version: 1.0",
             "Content-Type: text/html"]
          headers = "\r\n".join(headers)
          self.session.sendmail(
              self.email,
              self.email,
              headers + "\r\n\r\n" + body)
          print('- Message has been sent.')
  
  df = pd.read_csv('test.csv', error_bad_lines=False)
  
  for index, row in df.iterrows():
      print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
      comp_name = (row['name'])
      print('Email to: ' + comp_name)
      rec = (row['email'])
      print('Email to: ' + rec)
      gm = Gmail('email@gmail.com', 'password', rec)
      gm.send_message('email to ' + comp_name, '&lt;b&gt;This is a test&lt;b&gt;')
      print('-- Message for ' + rec + ' (' + comp_name + ') is completed.')
  
  print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
  print('*********************************')
  print('Finish reading through CSV.')
  print('*********************************')
  print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
  </code></pre>
  
  <p>Let me know if there is something wrong. I would really like this to work.</p>
  
  <p>Just so that you can see it is working, here is the other script I am testing it against (which is poorly formatted) and it is completely functioning properly.</p>
  
  <pre><code>import smtplib
  import pandas as pd
  
  df = pd.read_csv('test.csv', error_bad_lines=False)
  
  gmail_user = 'email@gmail.com'  
  gmail_password = 'password'
  
  for index, row in df.iterrows():
  
      sent_from = gmail_user  
      to = (row['email'])
      subject = 'Important Message'  
      body = 'Hey, whats up'
  
      rec = (row['email'])
      comp_name = (row['name'])
      print('Email to: ' + comp_name)
      print('Email to: ' + rec)
  
      email_text = """\  
      From: %s  
      To: %s  
      Subject: %s
  
      %s
      """ % (sent_from, to, subject, body)
  
      try:  
          server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
          server.ehlo()
          server.login(gmail_user, gmail_password)
          server.sendmail(sent_from, to, email_text)
          server.close()
  
          print ('-- Email sent!')
      except:  
          print ('-- Something went wrong...')
  
  print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
  print('*********************************')
  print('Finish reading through CSV.')
  print('*********************************')
  print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
  </code></pre>