title: UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 134: ordinal not in range(128)
body: <p>I'm trying to create a python program which includes sending an email and I'm getting the UnicodeEncodeError error. None of the solutions I've seen with this error work in my script. I tried to add <code>receiver = str(u' '.join(receiver).encode('utf-8'))</code> in the for loop but it doesn't work as well. Here's a part of my code (if you want I can post the whole code):</p>
  <pre><code>werewolfs = []
  
  def group_roles(group):
      for i in range(4):
          werewolfs.append(group[i])
  
  
  group_roles(group1)
  group_roles(group2)
  group_roles(group3)
  
  for receiver in werewolfs:
      receiver = str(u' '.join(receiver).encode('utf-8'))
      DATA = 'From:%s\nTo:%s\nSubject:%s\n\n%s' % (my_email, receiver, subject, werewolf_mail)
      server.sendmail(my_email, receiver, DATA)
  
  </code></pre>
  <p>This is the whole error message:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/home/dominikb/.config/JetBrains/PyCharmCE2020.3/scratches/werewolf.py&quot;, line 131, in &lt;module&gt;
      server.sendmail(my_email, receiver, DATA)
    File &quot;/usr/lib/python3.9/smtplib.py&quot;, line 859, in sendmail
      msg = _fix_eols(msg).encode('ascii')
  UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 134: ordinal not in range(128)
  </code></pre>
  <p>Does someone know the solution to this? That would be great. Thanks in advance!</p>