diff --git a/CHANGES.rst b/CHANGES.rst
index f15e8cf..5cd15bb 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -5,7 +5,9 @@
 4.3 (unreleased)
 ================
 
-- Nothing changed yet.
+- Fix SMTP authentication on Python 3. See `issue 16
+  <https://github.com/zopefoundation/zope.sendmail/issues/16>`_.
+
 
 
 4.2 (2018-10-10)
diff --git a/src/zope/sendmail/_compat.py b/src/zope/sendmail/_compat.py
index 8b7a587..d74ad35 100644
--- a/src/zope/sendmail/_compat.py
+++ b/src/zope/sendmail/_compat.py
@@ -1,4 +1,6 @@
 try:
     text_type = unicode
+    PY2 = True
 except NameError:  # pragma: NO COVER Py3k
     text_type = str
+    PY2 = False
diff --git a/src/zope/sendmail/mailer.py b/src/zope/sendmail/mailer.py
index 1b79bd6..6d14d34 100644
--- a/src/zope/sendmail/mailer.py
+++ b/src/zope/sendmail/mailer.py
@@ -1,3 +1,4 @@
+# coding=utf-8
 ##############################################################################
 #
 # Copyright (c) 2003 Zope Foundation and Contributors.
@@ -21,8 +22,10 @@ from smtplib import SMTP
 
 from zope.interface import implementer
 from zope.sendmail.interfaces import ISMTPMailer
+from zope.sendmail._compat import PY2
 from zope.sendmail._compat import text_type
 
+
 class _SMTPState(local):
     connection = None
     code = None
@@ -98,9 +101,9 @@ class SMTPMailer(object):
         if connection.does_esmtp:
             if self.username is not None and self.password is not None:
                 username, password = self.username, self.password
-                if isinstance(username, text_type):
+                if PY2 and isinstance(username, text_type):
                     username = username.encode('utf-8')
-                if isinstance(password, text_type):
+                if PY2 and isinstance(password, text_type):
                     password = password.encode('utf-8')
                 connection.login(username, password)
         elif self.username:

Encoding username/password to utf-8 is incompatible with Python 3.6's auth_login
When using zope.sendmail with an SMTP server that will ask you to perform auth_login then this will end in:

``` Python
  File "/Users/ctheune/Code/fc.support/lib/python3.6/site-packages/zope/sendmail/mailer.py", line 105, in send
    connection.login(username, password)
  File "/nix/store/g4zvkfn3znxz36j3rfnj8h9i7kpln293-python3-3.6.3/lib/python3.6/smtplib.py", line 721, in login
    initial_response_ok=initial_response_ok)
  File "/nix/store/g4zvkfn3znxz36j3rfnj8h9i7kpln293-python3-3.6.3/lib/python3.6/smtplib.py", line 630, in auth
    response = encode_base64(initial_response.encode('ascii'), eol='')
AttributeError: 'bytes' object has no attribute 'encode'
```

Unfortunately the documentation of smtplib doesn't explicitly mention what username/password should be, but apparently they (internally) expect that to be a string, not a bytes object. It looks a bit like this could also be a bug in Python as this would mean that we could ever only support ASCII usernames and passwords ... not sure what the standard says there. LOGIN is later encoded to base64 so 8-bit data seems fine, but I haven't seen a standard describing that UTF-8 would be expected there, so ... I guess not doing any encoding from our side and letting the latter code fail on non-ASCII characters seems fine ... 
diff --git a/src/zope/sendmail/tests/test_mailer.py b/src/zope/sendmail/tests/test_mailer.py
index 9c60c91..891d70d 100644
--- a/src/zope/sendmail/tests/test_mailer.py
+++ b/src/zope/sendmail/tests/test_mailer.py
@@ -1,3 +1,4 @@
+# coding=utf-8
 ##############################################################################
 #
 # Copyright (c) 2003 Zope Foundation and Contributors.
@@ -171,8 +172,8 @@ class TestSMTPMailer(unittest.TestCase):
         self.mailer.hostname = 'spamrelay'
         self.mailer.port = 31337
         self.mailer.send(fromaddr, toaddrs, msgtext)
-        self.assertEqual(self.smtp.username, b'foo')
-        self.assertEqual(self.smtp.password, b'evil')
+        self.assertEqual(self.smtp.username, 'foo')
+        self.assertEqual(self.smtp.password, 'evil')
         self.assertEqual(self.smtp.hostname, 'spamrelay')
         self.assertEqual(self.smtp.port, '31337')
         self.assertEqual(self.smtp.fromaddr, fromaddr)
@@ -190,8 +191,8 @@ class TestSMTPMailer(unittest.TestCase):
         self.mailer.hostname = 'spamrelay'
         self.mailer.port = 31337
         self.mailer.send(fromaddr, toaddrs, msgtext)
-        self.assertEqual(self.smtp.username, b'f\xc3\xb8\xc3\xb8')
-        self.assertEqual(self.smtp.password, b'\xc3\xa9vil')
+        self.assertEqual(self.smtp.username, 'føø')
+        self.assertEqual(self.smtp.password, 'évil')
 
     def test_send_auth_nonascii(self):
         fromaddr = 'me@example.com'

pip install -e .[test]
parse_log_pytest
pytest
coverage pytest
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///croot/attrs_1668696182826/work
certifi @ file:///croot/certifi_1671487769961/work/certifi
coverage==7.2.7
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1648562407465/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1671697413597/work
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pytest==7.1.2
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
transaction==4.0
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
zipp @ file:///croot/zipp_1672387121353/work
zope.component==6.0
zope.configuration==5.0.1
zope.event==5.0
zope.exceptions==5.1
zope.hookable==6.0
zope.i18nmessageid==6.1.0
zope.interface==6.4.post2
zope.location==5.0
zope.proxy==5.3
zope.schema==7.0.1
zope.security==6.2
-e git+https://github.com/zopefoundation/zope.sendmail.git@8ec710588bf3558d3969d22f4fff72c080435aea#egg=zope.sendmail
zope.testing==5.0.1
zope.testrunner==6.5

name: zope.sendmail
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib-metadata=4.11.3=py37h06a4308_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - typing_extensions=4.4.0=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.2.7
      - transaction==4.0
      - zope-component==6.0
      - zope-configuration==5.0.1
      - zope-event==5.0
      - zope-exceptions==5.1
      - zope-hookable==6.0
      - zope-i18nmessageid==6.1.0
      - zope-interface==6.4.post2
      - zope-location==5.0
      - zope-proxy==5.3
      - zope-schema==7.0.1
      - zope-security==6.2
      - zope-testing==5.0.1
      - zope-testrunner==6.5
prefix: /opt/conda/envs/zope.sendmail

src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_send_auth src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_send_auth_unicode
src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_abort_fails_call_close src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_abort_no_conn src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_interface src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_send src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_send_auth_nonascii src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_send_failQuit src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_send_multiple_same_mailer src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_send_multiple_threads src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_send_no_esmtp_with_username src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_send_no_tls_forced src/zope/sendmail/tests/test_mailer.py::TestSMTPMailer::test_vote_bad_connection src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_abort_fails_call_close src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_abort_no_conn src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_interface src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_send src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_send_failQuit src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_send_multiple_same_mailer src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_send_multiple_threads src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_send_no_esmtp_with_username src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_send_no_tls_forced src/zope/sendmail/tests/test_mailer.py::TestSMTPMailerWithNoEHLO::test_vote_bad_connection src/zope/sendmail/tests/test_mailer.py::test_suite
src/zope/sendmail/_compat.py CHANGES.rst src/zope/sendmail/mailer.py
src/zope/sendmail/_compat.py CHANGES.rst src/zope/sendmail/mailer.py