Manage yagmail.Client connections
masterIn CPython, yagmail.Client cleans up after itself automatically. However, for other implementations like PyPy, or to ensure reliable cleanup, use the client as an asynchronous context manager with the with statement.
You can also manually manage the connection lifecycle using .close() and .login() methods.
# Using a context manager (recommended for PyPy or explicit cleanup)
with yagmail.Client('mygmailusername', 'mygmailpassword') as yag:
yag.send(to='you@gmail.com', contents="Hello!")
# Manual management
yag = yagmail.Client('mygmailusername', 'mygmailpassword')
yag.send(to="you@gmail.com", contents="Hello!")