Skip to content

Commit 09b2a84

Browse files
committed
updated close logic and readme
1 parent 33d4771 commit 09b2a84

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

Diff for: README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ contents = ['This is the body, and here is just text http://somedomain/image.png
2222
yag.send('[email protected]', 'subject', contents)
2323
```
2424

25-
Or a simple one-liner (connection will automatically close):
25+
Or a simple one-liner:
2626
```python
2727
yagmail.SMTP('mygmailusername').send('[email protected]', 'subject', 'This is the body')
2828
```
@@ -87,7 +87,10 @@ Another convenience can be to save a .yagmail file in your home folder, containi
8787
yag = yagmail.SMTP('mygmailusername')
8888
```
8989

90-
Note that this connection is reusable, closable and when it leaves scope it will clean up after itself.
90+
Note that this connection is reusable, closable and when it leaves scope it will **clean up after itself in CPython**.
91+
92+
As [tilgovi](https://github.com/tilgovi) points out in [#39](https://github.com/kootenpv/yagmail/issues/39), SMTP does not automatically close in **PyPy**. The context manager `with` should be used in that case.
93+
9194

9295
### Usability
9396

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
MAJOR_VERSION = '0'
44
MINOR_VERSION = '5'
5-
MICRO_VERSION = '135'
5+
MICRO_VERSION = '136'
66
VERSION = "{}.{}.{}".format(MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION)
77

88
from setuptools.command.test import test as TestCommand

Diff for: yagmail/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__project__ = 'yagmail'
2-
__version__ = "0.5.135"
2+
__version__ = "0.5.136"
33

44
from .error import YagConnectionClosed
55
from .error import YagAddressError

Diff for: yagmail/yagmail.py

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __enter__(self):
7070
return self
7171

7272
def __exit__(self, exc_type, exc_val, exc_tb):
73+
self.close()
7374
return False
7475

7576
def set_logging(self, log_level=logging.ERROR, file_path_name=None):
@@ -383,6 +384,9 @@ def feedback(self, message="Awesome features! You made my day! How can I contrib
383384
""" Most important function. Please send me feedback :-) """
384385
self.send('[email protected]', 'Yagmail feedback', message)
385386

387+
def __del__(self):
388+
self.close()
389+
386390

387391
class SMTP_SSL(SMTP):
388392

0 commit comments

Comments
 (0)