from marrow.mailer import Mailer, Message
mailer = Mailer(dict(
transport = dict(
use = 'smtp',
host = 'smtp.office365.com',
port = 587,
tls='required',
username='username@test.com',
password='password')))
print('connection...')
mailer.start()
print('connected')
message = Message(author="from@test.com", to="to@test.com")
message.subject = "Testing Marrow Mailer"
message.plain = "This is a test."
print('send mail')
mailer.send(message)
print('disconnect')
mailer.stop()
This works great with python 2.7, but with python 3.7 (tested on 3.7.1 and 3.7.4), I have this error :
Delivery of message <157121638590.46272.10119950910494763987@server.local> failed.
Traceback (most recent call last):
File "C:\usr\Python37\lib\site-packages\marrow\mailer\manager\util.py", line 50, in __enter__
transport = pool.transports.get(False)
File "C:\usr\Python37\lib\queue.py", line 167, in get
raise Empty
_queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "minimal_test.py", line 32, in <module>
mailer.send(message)
File "C:\usr\Python37\lib\site-packages\marrow\mailer\__init__.py", line 149, in send
result = self.manager.deliver(message)
File "C:\usr\Python37\lib\site-packages\marrow\mailer\manager\immediate.py", line 41, in deliver
with self.transport() as transport:
File "C:\usr\Python37\lib\site-packages\marrow\mailer\manager\util.py", line 57, in __enter__
transport.startup()
File "C:\usr\Python37\lib\site-packages\marrow\mailer\transport\smtp.py", line 50, in startup
self.connect_to_server()
File "C:\usr\Python37\lib\site-packages\marrow\mailer\transport\smtp.py", line 86, in connect_to_server
connection.starttls(self.keyfile, self.certfile)
File "C:\usr\Python37\lib\smtplib.py", line 771, in starttls
server_hostname=self._host)
File "C:\usr\Python37\lib\ssl.py", line 412, in wrap_socket
session=session
File "C:\usr\Python37\lib\ssl.py", line 846, in _create
owner=self, session=self._session,
ValueError: server_hostname cannot be an empty string or start with a leading dot.
This works great with python 2.7, but with python 3.7 (tested on 3.7.1 and 3.7.4), I have this error :